On Feb 8, 9:16 am, Marnen Laibow-Koser <[email protected]> wrote:
> Andrew France wrote:
> > On 09/02/10 01:32, Marnen Laibow-Koser wrote:
> >> Andrew France wrote:
>
> >>> Hi,
>
> >>> I was thinking whether it would be more elegant for a view to call
> >>> methods on the controller rather than rely on instance variables.
>
> >> The trouble with this is that controller methods are actions, not
> >> getters.
>
> > It's quite common for controllers to have methods which are not directly
> > actions.
>
> Not in my applications.  It's inappropriate to put that much logic in
> the controller.
>
> The only exceptions are things like current_user, which can't really
> live anywhere else, and current_object, which is simply a refactoring of
> controller code.  Anything else belongs in a model or a helper.

I completely agree with Marnen. Fat models, skinny controllers.

Your example is a poor one - it's certainly appropriate to have a
@book instance variable in the BooksController. Your instinct is
correct about lots of instance variables, but they should usually be
replaced with model instance methods.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to