Anatomy of Rails Controller
A rails controller is usually associated with a model. (RESTful) with a few exceptions.
A rails controller ideally has only 5 methods/actions (create, index, show, update, destroy), before_filters and private supporting methods. Some controllers do not need some actions say, update & destroy if the business logic says so.
The 'before_filters' can be used for authentication & setting instance variables of the corresponding models.
The show, update & destroy actions need access to the instance variables. So you can set them in the before filter.
You can also white-label the params for the update action ( for security reasons ) using the permit parameter. Then you can require some attributes using the require method.
Code without 'conditionals' is a pleasure to read. You can work-around them using ||=
Also try to push as much logic as possible into the model. Adding scopes, methods etc.














