rubyonrailsin

A Ruby and Rails talk

Wednesday, March 10, 2010


Re: [Rails] Re: How to make an array available to all views.

by rubyonrailsin 0 comments



Share this post:
Design Float
StumbleUpon
Reddit

> But you are wrong.  The view should never, ever, ever touch the
> database.

Is it considered ok to call model methods if they do not touch the db,
or are model methods forbidden also?

I would say the view can call instance methods of the model (attributes - real and virtual) but no class methods.

So:

<%= @user.name %>

is OK, but:


is not.  It's a bit of a contrived example, but there you go.  Accessing the model through instance variables you've created is OK, going directly to the model bypassing the controller is not.

Cheers,


Andy

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive