RESTful applications built with script/generate have a lot of repetitive code. Each generated controller will define default “index” “create” “new” “update” and “destroy” methods that looks similar from controller to controller.
There are at least FOUR plugins that aim to DRY up RESTful controllers each with their own benefits and weaknesses:
- make_resourceful - There’s a great Railscast on make_resourceful.
- resource_controller Provides a super-class controller that you inherit from. Pretty sweet at handling nested resources…..but don’t confuse it with…
- resources_controller — which uses a declarative syntax instead of a superclass. I like seeing “resources_controller_for :foos” in my code.
- resource_this — Heavily uses before_filters, if you’d prefer to see things that way.
I am working on a longer, more in-depth comparison of the available frameworks. but I’ve gotta tell you, a “winner” needs to shake out of this list. Having four very strong and useful, but VERY DIFFERENT, ways to DRY up controllers is not beneficial.
Do you remember when there were six ways to Paginate records in a Rails app? Now we use “will\_paginate”, and that’s how it’s done. Everyone knows how to use will_paginate, and it’s terse, well tested, and well supported.
So, which framework do you use? Let me know. I’m interested.
Add New Comment
Viewing 4 Comments
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Add New Comment