Forum: Ruby on Rails How to implement a global partial?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Df0a460118ef876e45b13b8c1a471454?d=identicon&s=25 Marston A. (marstoni)
on 2006-05-12 22:57
Quick question:

Whats the easiest way to implement a global partial?  Where I can call
one partial from many different controllers (err controller views)?
0697ddea023b4297f0539794b2b3f518?d=identicon&s=25 Chris Ingrassia (Guest)
on 2006-05-12 23:01
(Received via mailing list)
IIRC, you can simply prefix the partial name with a path and it will
work.

ex:

	render :partial => "partials/myglobalpartial"

will render app/views/partials/_myglobalpartial.rhtml

Is that what you were looking for?
Eed3ca2591560a2dd91222d9b62f882d?d=identicon&s=25 Ryan Prins (Guest)
on 2006-05-13 00:36
(Received via mailing list)
Why not put it in the layouts directory? You could just have
/layouts/_mypartial.rhtml and call like render :partial =>
"layouts/mypartial"

I haven't tried it, so I can't verify if it works or not, but I'd much
rather keep items that are global in the layouts directory where my
layout
is stored. Of course, I am assuming that you are using a layout... which
would be best if you are using the same base markup for all of your
pages.

HTH,
Ryan
Df0a460118ef876e45b13b8c1a471454?d=identicon&s=25 Marston A. (marstoni)
on 2006-05-13 00:39
Excellent, that was exactly what I was looking for.  Thanks guys.
This topic is locked and can not be replied to.