[LRUG] Are before_filters abused in Rails?

Riccardo Tacconi rtacconi at gmail.com
Fri Mar 23 04:02:45 PDT 2012


Jose said that instead of using inherited resources we should use Rails 3
responders, but they seem to me not so handy. I am wondering which is the
best thing to do.

On 23 March 2012 11:26, Ash Berlin <ash_lrug at firemirror.com> wrote:

>
> On 22 Mar 2012, at 12:50, Jay Caines-Gooby wrote:
>
> > On 22 March 2012 12:18, mudge <mudge at mudge.name> wrote:
> >> Good afternoon all,
> >>
> >> I posted this on Twitter a while back but seeing as the list has been
> >> a flurry of activity recently, I thought I'd post it here to gather
> >> more debate.
> >>
> >> Do you use before_filters in your controllers to DRY up the
> >> instantiation of variables like so?
> >>
> >> class MyController < ApplicationController
> >>  before_filter :load_model, :only => [:show, :edit, :update, :destroy]
> >
> > resource_this https://github.com/jnewland/resource_this does exactly
> > this and we use it extensively. It means that you get extremely terse
> > controllers for basic  CRUD, and you can customise them really easily
> > for additional flexibility.
> >
> > I also like the helper_method style
> > https://gist.github.com/2007669#file_helper_method_controller.rb
> >
> > The main problem with any of these, is that in basic controllers, the
> > signpost of a 'helper_method :model' or 'resource_this' at the top of
> > the controller are easy to spot, but add in all your validation code,
> > relationships, etc, etc they can be easy to miss, but the DRYness of
> > them certainly makes it worthwhile.
>
>
> inherited_resources does both of these automatically (s/model/resource/
> for the helper method) - http://github.com/josevalim/inherited_resources/
>
> After having a quick glance at resource_this inherited_resources seems to
> largely similar but might be easier to override behaviour on one action
> (though I only glanced at the docs for r_t quickly)
>
> -ash
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>



-- 
Riccardo Tacconi
Ruby on Rails and PHP development - System Administration
VIRTUELOGIC LIMITED

http://github.com/rtacconi
http://riccardotacconi.blogspot.com
http://twitter.com/rtacconi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20120323/24ec4b7a/attachment.html>


More information about the Chat mailing list