Rails Tip #07 - Adding more routes

in ruby •  7 years ago 

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
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  
  ·  7 years ago (edited)

Thank you for your kind information, @ bilal-haider. regards from me @wik

You are welcome :) are you a programmer yourself too ?

what a good article thanks for some doubts I had. grateful. I voted and reesteemed.

What doubts you had ?

Great information, thanks Bilal :3

You are welcome bro :)

I think you have been talking to people who just leave a comment for commenting sake. Maybe even done by bots.

I am actually a programmer, but never tried anything related to rails. Most of the time it is PHP.

I haven't seen all your posts on the subject but it may help to add the 'tutoral' tag or even something like 'bilal-haider-tutorial'. This will make it easier for people to get an overview.

Are you doing just unrelated snippets of code, or is there a bigger plan behind it?

There is a bigger plan behind it ;) i know mostly are bot comments, just to dump my SP i vote and comment on them. :D

So what is the bigger plan?
Often programming tutorials lead to a certain goal.
Create a simple app or something.
Is that what you are aiming for?

I am infact working on an application, I just pick useful things and post them here, just in case, if i needed to look back at them in future..
these articles are key notes for me really ..

The informative post, thanks for sharing.

You are always welcome bro :)