seems like this should be easy, but it is evading me... Assume: http://myserver/controller-x/action-x In app/views/controller-x/action-x.rhtml I have: <%= render(:partial => ''partial-x'') %> And this will render: app/views/controller-x/_partial-x.rhtml Now - I want to render _partial-x.rhtml from a different controller. The only way I''ve been able to make this work is to copy _partial-x.rhtml into the views folder for the other controller, but that''s not very Railsy or DRY. Is it possible for me to render a particular partial from several different controllers without duplicating the partial? Thanks. -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Cayce Balara wrote:> > Now - I want to render _partial-x.rhtml from a different controller. The > only way I''ve been able to make this work is to copy _partial-x.rhtml > into the views folder for the other controller, but that''s not very > Railsy or DRY. > > Thanks.i would try this, say the view folder is called posts: <%= render(:partial => ''/posts/partial-x'') %> that should work. -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Cayce Balara
2006-Aug-26 17:50 UTC
Re: how to render controller x partial from controller y?
Oh man - so easy. Really appreciate it, J. c. Jonny wrote:> Cayce Balara wrote: >> >> Now - I want to render _partial-x.rhtml from a different controller. The >> only way I''ve been able to make this work is to copy _partial-x.rhtml >> into the views folder for the other controller, but that''s not very >> Railsy or DRY. >> >> Thanks. > > i would try this, say the view folder is called posts: > > <%= render(:partial => ''/posts/partial-x'') %> > > > that should work.-- 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-/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 -~----------~----~----~----~------~----~------~--~---