Greg Hauptmann
2008-Dec-04 07:35 UTC
is passing model objects to a view ok (i.e. best practice)???
Hi, A Rails Best Practice question: Question - Is passing model objects (or a collection of model object) from the controller to a view best practice is rails? i.e. or is one supposed to create the most minimal set of data all ready to display in the form of array/hashes and pass this to a view? (the latter approach adds a bit more plumbing work) Thanks --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thorsten Müller
2008-Dec-04 09:59 UTC
Re: is passing model objects to a view ok (i.e. best practice)???
Hmm, not sure if I understand that right. Assume: @articles = Article.find(:all) So I want to display those articles. (And I would just use this @articles in the views) Don''t see, how I could "split" that an further. Sure, I could create and array and assign every article to it. Would be nonsense I think. Or say, I want to display only the article names. Then I could collect those into an array. That would make slightly more sense, but I wouldn''t do it anyway. Because: - One more step, extra work without any extra use - Very likely, that soon enough I want to display more data. - Would make the code difficult to read. - Nobody does it that way as far as I know. Never seen a piece of code in any tutorial or oss project doing it. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Greg Hauptmann
2008-Dec-04 11:52 UTC
Re: is passing model objects to a view ok (i.e. best practice)???
ok - yes that makes sense to me for Rails too (just checking, as I''ve had a Java background) On Thu, Dec 4, 2008 at 7:59 PM, Thorsten Müller <thorsten-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org> wrote:> > Hmm, not sure if I understand that right. > Assume: > > @articles = Article.find(:all) > > So I want to display those articles. (And I would > just use this @articles in the views) > Don''t see, how I could "split" that an further. > Sure, I could create and array and assign every article to > it. Would be nonsense I think. > > Or say, I want to display only the article names. > Then I could collect those into an array. That would > make slightly more sense, but I wouldn''t do it anyway. > Because: > - One more step, extra work without any extra use > - Very likely, that soon enough I want to display more data. > - Would make the code difficult to read. > - Nobody does it that way as far as I know. Never seen a piece > of code in any tutorial or oss project doing it. > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 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 -~----------~----~----~----~------~----~------~--~---