-
Notifications
You must be signed in to change notification settings - Fork 0
Progress
5/27:
created models, views, controllers for people and groups. controller/view is very basic, for example the people view generates a page with each person’s name and below the name shows all the groups associated with this person.
Used rake db:migrate
to create the tables
To see it working I used the ruby console to add a few basic rows to each table. Here’s how to do it so rails automatically handles the join table:
johnny@johnny-laptop:~/Documents/rails/acm_site$ script/console
Loading development environment (Rails 2.3.5)
>> me = Person.new
=> #<Person id: nil, name: nil, email: nil, created_at: nil, updated_at: nil>
>> me.name =
?> “johnny”
=> “johnny”
>> me.name
=> “johnny”
>> me.save
=> true
>> u = Person.new
=> #<Person id: nil, name: nil, email: nil, created_at: nil, updated_at: nil>
>> u.name = “DeGrassi”
=> “DeGrassi”
>> me.save
=> true
>> u.save
=> true
#created two new Person objects and saved them to the people table
>> me.groups.create
=> #<Group id: 1, name: nil, created_at: “2010-05-27 07:23:13”, updated_at: “2010-05-27 07:23:13”>
>> me.groups.create
=> #<Group id: 2, name: nil, created_at: “2010-05-27 07:23:17”, updated_at: “2010-05-27 07:23:17”>
>> me.groups0.people
=> [#<Person id: 1, name: “johnny”, email: nil, created_at: “2010-05-27 07:22:23”, updated_at: “2010-05-27 07:22:23”>]
>> u.groups.create
=> #<Group id: 3, name: nil, created_at: “2010-05-27 07:23:45”, updated_at: “2010-05-27 07:23:45”>
>> u.groups
=> [#<Group id: 3, name: nil, created_at: “2010-05-27 07:23:45”, updated_at: “2010-05-27 07:23:45”>]
>> me.groups
=> [#<Group id: 1, name: nil, created_at: “2010-05-27 07:23:13”, updated_at: “2010-05-27 07:23:13”>, #<Group id: 2, name: nil, created_at: “2010-05-27 07:23:17”, updated_at: “2010-05-27 07:23:17”>]
>> u.groups0.people
=> [#<Person id: 2, name: “DeGrassi”, email: nil, created_at: “2010-05-27 07:23:04”, updated_at: “2010-05-27 07:23:04”>]
- used each Person to create new groups, which are now linked to that person, as (Person).groups shows. Now make sure to save all the
- people and groups. Here’s how to link two rows that are already created:
>> u = Person.all1
=> #<Person id: 2, name: “DeGrassi”, email: nil, created_at: “2010-05-27 07:23:04”, updated_at: “2010-05-27 07:23:04”>
>> grp = Group.all0
=> #<Group id: 1, name: “winners”, created_at: “2010-05-27 07:23:13”, updated_at: “2010-05-27 07:48:43”>
>> u.groups << grp
=> [#<Group id: 3, name: “catz”, created_at: “2010-05-27 07:23:45”, updated_at: “2010-05-27 07:58:31”>, #<Group id: 1, name: “winners”, created_at: "2010-05-
also I threw on some CSS that came with the tutorial.
6/6
signup form is built. it filters for invalid user info, then POSTs the new user data to people. PeopleController.create handles the request and the model Person encrypts the password before storing it.
now to make the login/edit/logout functions
6/7
people who have signed up can now log in, edit their basic info and which groups they are in, and log out. login and logout are handled in sessions_controller.rb and sessions_helper.rb, where a cookie is placed on the user’s browser to identify which person is logged in. SessionsHelper gives us, among others, a signed_in? method which returns whether the current request came from a browser with a valid login cookie, and current_person, which returns the logged in user or nil if the current request came from a browser not logged in.
added some comments to people_controller.rb, sessions_controller.rb, and sessions_helper.rb. let me know if they leave anything unclear
6/10
Filled the database with names, emails, and interests of members who we have so far. I think pulling the madScience branch would get you the populated database.
8/16
Created a migration to add role to people. Plan on using this for editing content and/or creation of events, etc.