Ruby Active Record Associations in Rails Using Associations in Your App Creating an Associated Record

caven xu
caven xu
Pro Student 13,400 Points

How about separately writing `new` `create` in comments_controller ?

I 'noticed that we can use different ways to create a comment.

  1. use the way in this video: in posts/show, then call[@post, comment] in partial;

  2. use: form_for do |f| in partial

another way is create a views/comments/new then write new method(@post = Post.find(params[:post_id]), @comment = in comments_controller, finally call @comment in view

I haven't seen the first way before. Is this shorthand method new to rails? Which one is more usual in production?