Five great tricks with Rails views
Bruce Williams has a great set of articles going on on his blog called "Rails Views". Each one looks at a different aspect of Rails' views and templates system and how you can use it in a cool or different way. You are bound to learn something or come up with some ideas on how to make your views more efficient (I sure have!). Here are some of the recent posts in the series:
- Internal Plugins - Bruce demonstrates a great way to separate common functionality in your applications using plugins. Lots of food for thought here.
- Helpers That Take Blocks - A look at creating your own helps that take blocks, like form_for or content_for.
- form_for - form_for is a cleaner and more elegant way of defining forms in your views, compared to the old form_tag method. Bruce gives a basic introduction (with code).
- Using render :update rather than RJS - Bruce makes a brave statement in suggesting that, in many cases, RJS is better off in the controller than in the views. His argument makes sense.
- Use update_page in link_to_function - A look at using RJS constructions from directly in regular RHTML view templates. Great idea!