Search code examples
ruby-on-railsrubyruby-on-rails-3restruby-on-rails-3.1

Where can I read about REST in ruby on rails?


I've noticed a pattern in the tutorials I've been using. When ever a sign up form is being created a UsersController is used and there are always specific actions e.g. new, create, edit, update, destroy. Although I have slight understanding of why these actions are used I do find myself becoming confused.

Can anyone point me to documentation or a screencast where I can learn about REST and "convention over configuration". Seeing as I'm a few months into rails I'm still in the early stages of learning and now would be a good time to pick up some GOOD habits.

I'm working on a sign up system and have reached the stage to build the password reset. I will go about creating a Passwords controller but then will need to have a form for users to enter a password. I can use the "new" action for this right and create a new instance of my User model/class and store it in an instance variable @user so my view can access it. I know things like this work.. but don't understand why it has to be in a new action. Wouldn't it work under an action called 'reset' or 'dog' ?

Is there a reason why I put the code to help create /store a user in the database under the create action? or is this just good practice because it helps me understand exactly what is going on at first glance? Is it so I can take advantage of rails features such as routing...resources?

I'm trying to understand more..

Thanks in advance for responses..


Solution

  • Try these this link - http://en.wikipedia.org/wiki/Representational_state_transfer

    You'll get a better understanding of what REST actually means and why its good. Also the actions new, edit, create, update, delete, index are just Rails' way of implementing "Convention over configuration". If you want to use actions with custom names, you need to do some configuration.

    This should help you - http://railscasts.com/episodes/35-custom-rest-actions

    Let me know if this was helpful.

    Sahil