Wes Gamble
2006-Mar-14 00:01 UTC
[Rails] Best way to use partial rendering in global layout
I have a global layout in application.rhtml and I''d like to render a partial template within it. Currently, I have this: <%= render (:partial => ''side_nav'') %> but it seems to be looking in the controller specific view directory. What is the best way to do handle controller - global partial rendering? Wes -- Posted via http://www.ruby-forum.com/.
Wes Gamble
2006-Mar-14 00:08 UTC
[Rails] Re: Best way to use partial rendering in global layout
ANSWER: Create a "shared" directory under app/views and do: <%= render ( :partial => ''shared/side_nav'' ) %> THANKS DAVE THOMAS! Wes Wes Gamble wrote:> I have a global layout in application.rhtml and I''d like to render a > partial template within it. > > Currently, I have this: > > <%= render (:partial => ''side_nav'') %> > > but it seems to be looking in the controller specific view directory. > > What is the best way to do handle controller - global partial rendering? > > Wes-- Posted via http://www.ruby-forum.com/.
What if you want to use a global partial most of the time, but sometimes want to override it? Would it add any value to have rails check the controller specific directory first, and then automatically look in shared/global/layouts/whatever if not found? Seems intuitive to me, but may just mean higher complexity with no real gain. -- View this message in context: http://www.nabble.com/Best-way-to-use-partial-rendering-in-global-layout-t1275884.html#a3393886 Sent from the RubyOnRails Users forum at Nabble.com.
Wes Gamble
2006-Mar-14 15:53 UTC
[Rails] Re: Best way to use partial rendering in global layout
I think that''s how it works now, actually. I scaffolded a new controller and the default layout that was generated got used until I removed it, and then the global one got used. Wes Lucifron wrote:> What if you want to use a global partial most of the time, but sometimes > want > to override it? > > Would it add any value to have rails check the controller specific > directory > first, and then automatically look in shared/global/layouts/whatever if > not > found? Seems intuitive to me, but may just mean higher complexity with > no > real gain. > -- > View this message in context: > http://www.nabble.com/Best-way-to-use-partial-rendering-in-global-layout-t1275884.html#a3393886 > Sent from the RubyOnRails Users forum at Nabble.com.-- Posted via http://www.ruby-forum.com/.
Wes Gamble wrote:> > I think that''s how it works now, actually. > > I scaffolded a new controller and the default layout that was generated > got used until I removed it, and then the global one got used. > > WesLayouts work this way, yes, but not partials. -- View this message in context: http://www.nabble.com/Best-way-to-use-partial-rendering-in-global-layout-t1275884.html#a3401727 Sent from the RubyOnRails Users forum at Nabble.com.
Wes Gamble
2006-Mar-14 18:13 UTC
[Rails] Re: Best way to use partial rendering in global layout
That''s right. I don''t know - I think someone would find a good use for that feature with partials. Wes Lucifron wrote:> Wes Gamble wrote: >> >> I think that''s how it works now, actually. >> >> I scaffolded a new controller and the default layout that was generated >> got used until I removed it, and then the global one got used. >> >> Wes > Layouts work this way, yes, but not partials. > > -- > View this message in context: > http://www.nabble.com/Best-way-to-use-partial-rendering-in-global-layout-t1275884.html#a3401727 > Sent from the RubyOnRails Users forum at Nabble.com.-- Posted via http://www.ruby-forum.com/.