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

On 10 March 2010 15:15, Marnen Laibow-Koser <lists@ruby-forum.com> wrote:
> Sharagoz -- wrote:
>>>> If it is literally something as simple as MyArray.all I believe there
>>>> is nothing wrong with calling the model direct from the view.
>
> 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?

Colin

>
>>>>
>>>
>>> It's dirty, horrible, bad form, breaks the separation of layers...
>> Beware of the MVC police Colin, this suggestion will certanly not get
>> good housekeeping seal of approval :D
>>
>> I agree through. I'm not gonna add a before filter just to set
>> MyArray.all into a class variable. I'd rather call it directly and claim
>> to be pragmatic.
>
> Claim all you like.  The fact is that in MVC architecture, database
> queries don't belong in the view.  A before_filter is the proper place
> for this.
>
> Best,
> --
> Marnen Laibow-Koser
> http://www.marnen.org
> marnen@marnen.org
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> 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.
>
>

--
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