Rails Tip #07 - Adding more routes

Words
72
Reading
1 min
Listen
Play
8y

Adding routes

Create a resource for posting comments

when we create a resource for lets say courses we do this

resources :courses

What if we want to create a resource for comments on courses, that's actually pretty easy to do that.
you do that by adding a block, and passing in your comments resource,
and if you only want comments to be created . then you specify with only: [:create, :destroy] option ..

  resources :courses do
    resources :comments, :controller => "course_comments", only: [:create]
  end
Rails Tip #07 - Adding more routes | Ecency