forked from kudelabs/roc-lab3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNOTES
More file actions
52 lines (31 loc) · 1.3 KB
/
NOTES
File metadata and controls
52 lines (31 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
DRAFT VERSION
- Getting started
Start from your own version of roc-lab1, or get it from the repo:
git clone git://github.com/kudelabs/roc-lab2.git
$ rake db:migrate
1. add user model, add relationships to messages, and replies.
$ rails generate model user name:string email:string password:string
2. rails generate migration add_user_to_messages_and_replies
add_column :messages, :user_id, :reference
add_column :replies, :user_id, :reference
add => has_many :messages, :replies
add => belongs_to :user
rake db:migrate
3. $rails console
user = User.create(:name=>'adeh',:email=>"adeh@kudelabs.com",:password=>'test')
msg = user.messages.create(:body=>'hellow haha')
reply = msg.replies.create(:body=>"reply to myself")
reply.user = user
4. edit views, replace placeholder "someone" to be real users
start server and then go to see the effect from console.
5. create user, sessions controllers
$rails generate controller users new
$rails generate controller sessions new
add before_filter :require_logged_in
helper_method :current_user, :logged_in?
6. add routes:
match 'login' => "sessions#new"
match 'logout' => "sessions#destroy"
match 'signup' => "users#new"
7. finish up sessions#new, user#new and then sessions#destroy
8. update message#create, reply#create to add user association.