Luke
2011-Jan-21 18:49 UTC
What''s the rails way to display data from multiple models on one page
Hi there, I''m working on a little portfolio-site to get to know rails a little better. On this site I have a blog, a gallery (my portfolio) and other stuff for which each I created a model. On the start-page I want to show a bit of everything - some of the recent blog-entries, some pictures from the gallery and so on. Now I was wondering - what''s the rails way to do this? Would you just create a controller and a view and load the data from multiple models (blog, gallery, ...) in the controller? Or would you create a new model that just has_many of the other models? Are there other, better ways? How would you accomplish this in rails? Thanks in advance, Luke -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Walter Lee Davis
2011-Jan-21 18:57 UTC
Re: What''s the rails way to display data from multiple models on one page
On Jan 21, 2011, at 1:49 PM, Luke wrote:> Hi there, > > I''m working on a little portfolio-site to get to know rails a little > better. On this site I have a blog, a gallery (my portfolio) and > other stuff for which each I created a model. On the start-page I > want to show a bit of everything - some of the recent blog-entries, > some pictures from the gallery and so on. Now I was wondering - > what''s the rails way to do this? Would you just create a controller > and a view and load the data from multiple models (blog, > gallery, ...) in the controller? Or would you create a new model > that just has_many of the other models? Are there other, better > ways? How would you accomplish this in rails? > > Thanks in advance, > LukeI usually make a home_controller, map my :root to one of its methods, and load up whatever models I need inside that method. I generally use that same controller for site-wide things like search results or contact us or about this site. Walter -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Luke
2011-Jan-24 10:44 UTC
Re: What''s the rails way to display data from multiple models on one page
Ok, thanks Walter! -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.