I watched a Rails code review by Jamis Buck and Marcel Molina Jr.
- difference between
Integer(value)will raise an exception if the value is not an integer
- strive for “symbolics”
- wrap complex condition statements into intention-revealing methods
- keep abstractions of the same level together in code (1 level of abstraction for a specific scope)
- problem: checking a few params and validate them (inside a
- solution: use the
rescueclause and create an
exists!inside the model, and let the controller handle the flow
- See this for a good example.
- skinny controllers, short action methods
- don’t be afraid to create models that don’t inherit
- make simple actions explicit in the controller
Avoid implicit (absent) actions in the controller; make it explicit:
with view helper code that looks like:
concat(block.call, block.binding) if condition
instead of using arbitrary instance flag which was set in the controller:
This allows you to do pre/post processing (e.g. encapsulating the editable content inside a
div), without repeating it everywhere in your view template (since it would only be in your view helper).