Graham Farrell
2010-Mar-20 16:58 UTC
How to create an index page with data from other contollers
Hi all, First I''m new to RoR so if I''m asking a question thats simple sorry but I can''t find the answer on google. I have a number of controllers that are working fine and I''ve got the foreign keys etc working. What I''m looking to do now is have an index page that will have information displayed from lets say 3 of these controllers on the page with links to other pages. Can I ask someone to point me in the right direction, do I have to create a new controller for this (surely not as this goes against DRY) Thanks, Graham -- 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-/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 Pearce
2010-Mar-21 08:28 UTC
Re: How to create an index page with data from other contollers
Hiya Graham, It depends on your setup really but I would say in this case you would want another controller. If you''ve put all the shared html into partials then on the new index page you would just need to do a few <%= render :partial => ''PARTIAL_NAME''%> to pull in the html you need. http://api.rubyonrails.org/classes/ActionView/Partials.html http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials Cheers Luke -- 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-/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.
Graham Farrell
2010-Mar-21 20:52 UTC
Re: How to create an index page with data from other contollers
Luke Pearce wrote:> Hiya Graham, > > It depends on your setup really but I would say in this case you would > want another controller. > > If you''ve put all the shared html into partials then on the new index > page you would just need to do a few <%= render :partial => > ''PARTIAL_NAME''%> to pull in the html you need. > > http://api.rubyonrails.org/classes/ActionView/Partials.html > > http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials > > Cheers > LukeThanks for the advice Luke I''ll use a new controller for the index page as some of the other pages don''t have partials. Can I ask how I can link the contollers should I include attributes from the other controllers index defs etc, such as myindexcontroller def index @Businesss = Business.all #from the business controller <html to show business list> end end cheers, Graham -- 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-/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.
Colin Law
2010-Mar-22 10:40 UTC
Re: Re: How to create an index page with data from other contollers
On 21 March 2010 20:52, Graham Farrell <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Luke Pearce wrote: >> Hiya Graham, >> >> It depends on your setup really but I would say in this case you would >> want another controller. >> >> If you''ve put all the shared html into partials then on the new index >> page you would just need to do a few <%= render :partial => >> ''PARTIAL_NAME''%> to pull in the html you need. >> >> http://api.rubyonrails.org/classes/ActionView/Partials.html >> >> http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials >> >> Cheers >> Luke > > > Thanks for the advice Luke I''ll use a new controller for the index page > as some of the other pages don''t have partials. > Can I ask how I can link the contollers should I include attributes from > the other controllers index defs etc, such as > > myindexcontroller > > def index > > @Businesss = Business.all #from the business controllerBusiness.all is not from the business controller, it is the Business model. You can call this from any controller. Colin -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.