Cyril Rouyer
2013-Mar-28 08:20 UTC
Parent'' show view and nested resources - Best practices ?
Hi everybody, First, sorry for my poor english, I will try to be clear :) I''m wondering what are the best practices in order to obtain a view showing data on a parent object, with sub-tabs, each tab for a nested resource. Imagine that you have a Contact model. Each contact has : - documents, - participations to meetings, - comments (which could be polymorphic) - ... When you access to the show page of the contact, you''d like to see contact information at the top of the page, and under these information, a tab-bar, each tab for each nested-resource : documents, meetings, comments, ... Ho do you do this kind of layouts / views ? A friend explain me that I can use the inherited_resources gem, which is really useful to abstract and handle nested_controllers, but I still don''t find a *good* solution for the layouts/view. Thank you by advance -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Q_l3Y7ZQhhwJ. For more options, visit https://groups.google.com/groups/opt_out.
BalaRaju Vankala
2013-Mar-28 15:52 UTC
Re: Parent'' show view and nested resources - Best practices ?
I think no need to use any gem. Its better to you learn how to use nested resources . *www.guides.rubyonrails.org/routing.html * On Thu, Mar 28, 2013 at 1:50 PM, Cyril Rouyer <cyril.rouyer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Hi everybody, > > First, sorry for my poor english, I will try to be clear :) > > I''m wondering what are the best practices in order to obtain a view > showing data on a parent object, with sub-tabs, each tab for a nested > resource. > > Imagine that you have a Contact model. Each contact has : > > - documents, > - participations to meetings, > - comments (which could be polymorphic) > - ... > > > When you access to the show page of the contact, you''d like to see contact > information at the top of the page, and under these information, a tab-bar, > each tab for each nested-resource : documents, meetings, comments, ... > > Ho do you do this kind of layouts / views ? > > A friend explain me that I can use the inherited_resources gem, which is > really useful to abstract and handle nested_controllers, but I still don''t > find a *good* solution for the layouts/view. > > Thank you by advance > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/Q_l3Y7ZQhhwJ. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- ---------------------------------------------------------------------------------------------------- Thank You. Best Wishes, BalaRaju Vankala, 8886565300. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Gintautas Šimkus
2013-Mar-28 16:15 UTC
Re: Parent'' show view and nested resources - Best practices ?
How about each tab Ajax-linking (link_to <...>, :remote => true) to documents, participants, comments controllers'' respective index actions, which render render inline content via Ajax call to a dedicated space (under "tabs") and doing all the other stuff of marking the correct tab "active"? For example "Documents tab" (not tested, basically a concept): link_to "Documents", contact_documents_path(@contact), :remote => true then you''d have documents#index action and documents/index.js.haml template that''d populate #tab_content div which is just under your general Contact information, as you described; the entry point would be contacts#show action; you''d assign @contact there. And you nest the resources something like: resources :contacts do resources :documents resources :participants resources: comments end Just brainstorming, feel free to disregard ;) 2013/3/28 BalaRaju Vankala <foreverbala4u-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> I think no need to use any gem. Its better to you learn how to use nested > resources . > > *www.guides.rubyonrails.org/routing.html * > > > > On Thu, Mar 28, 2013 at 1:50 PM, Cyril Rouyer <cyril.rouyer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote: > >> Hi everybody, >> >> First, sorry for my poor english, I will try to be clear :) >> >> I''m wondering what are the best practices in order to obtain a view >> showing data on a parent object, with sub-tabs, each tab for a nested >> resource. >> >> Imagine that you have a Contact model. Each contact has : >> >> - documents, >> - participations to meetings, >> - comments (which could be polymorphic) >> - ... >> >> >> When you access to the show page of the contact, you''d like to see >> contact information at the top of the page, and under these information, a >> tab-bar, each tab for each nested-resource : documents, meetings, comments, >> ... >> >> Ho do you do this kind of layouts / views ? >> >> A friend explain me that I can use the inherited_resources gem, which is >> really useful to abstract and handle nested_controllers, but I still don''t >> find a *good* solution for the layouts/view. >> >> Thank you by advance >> >>-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Cyril Rouyer
2013-Mar-29 09:48 UTC
Re: Parent'' show view and nested resources - Best practices ?
Hi, thank you for your answers Le jeudi 28 mars 2013 09:20:10 UTC+1, Cyril Rouyer a écrit :> > Hi everybody, > > First, sorry for my poor english, I will try to be clear :) > > I''m wondering what are the best practices in order to obtain a view > showing data on a parent object, with sub-tabs, each tab for a nested > resource. > > Imagine that you have a Contact model. Each contact has : > > - documents, > - participations to meetings, > - comments (which could be polymorphic) > - ... > > > When you access to the show page of the contact, you''d like to see contact > information at the top of the page, and under these information, a tab-bar, > each tab for each nested-resource : documents, meetings, comments, ... > > Ho do you do this kind of layouts / views ? > > A friend explain me that I can use the inherited_resources gem, which is > really useful to abstract and handle nested_controllers, but I still don''t > find a *good* solution for the layouts/view. > > Thank you by advance >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/wQK0szJt5LcJ. For more options, visit https://groups.google.com/groups/opt_out.