[LRUG] Proffer and introducing constraints to Rails

Graham Ashton graham at effectif.com
Tue Apr 3 00:58:07 PDT 2012

On 3 Apr 2012, at 08:19, Andrew Stewart <boss at airbladesoftware.com> wrote:

> The instance variable approach is impure but I don't mind because it doesn't cause me any problems.

Sure. Calling a method in a view is less brittle though (eg when extracting template code to partials with locals). So while it's a bit more to write in the controller, I'm happy to decouple the view and controller a bit. I like the helper method trick.

The big win when you start being explicit about this stuff is that you document your intent for those that follow you. If you need an actual instance variable in a controller a future reader of your code could assume that you made it to use in a view, and take longer to understand what's going on. So there's potential for confusion, which I think is much more unfortunate than a bit of inconvenient typing up front.

I like proffer. I'm going to stick to helper methods, but I wish Rails had been this explicit from the outset.

More information about the Chat mailing list