Forum: Ruby on Rails Where to put partials called from the application layout

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.
F50f5d582d76f98686da34917531fe56?d=identicon&s=25 Peter Szinek (Guest)
on 2006-05-21 21:16
(Received via mailing list)
Hello,

My main application layout, app/views/layout/application.rhtml looks
like this:

something
render partial_1
something else
render partial_2
something else
render partial_3

The partials are not really doing anything, i use them to keep the
layout modular (i.e . to have ~30 lines instead of 200). Now, the
question is where to put _partial_1.rhtml, _partial_2.rhtml,
_partial_3.rhtml.
If i am putting them to app/views/layouts, they are not found when a
view using this layout (e.g. view of the controller foo) is rendered -
but i don't want to put them into app/views/layouts/foo/ either since if
i am going to use the same layout to render the controller bar, i will
have to copy them there too, which not DRY.
I am quite sure this is a noob question, so what is the standard way to
do this?

TIA,
Peter
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Kevin Olbrich (Guest)
on 2006-05-21 21:34
(Received via mailing list)
On Sunday, May 21, 2006, at 9:14 PM, Peter Szinek wrote:
>render partial_3
>I am quite sure this is a noob question, so what is the standard way to
>do this?
>
>TIA,
>Peter
>_______________________________________________
>Rails mailing list
>Rails@lists.rubyonrails.org
>http://lists.rubyonrails.org/mailman/listinfo/rails

create a directory called 'shared' in your view path.

then call them as 'shared/partial1' and they should all go to the same
place.


_Kevin
F50f5d582d76f98686da34917531fe56?d=identicon&s=25 Peter Szinek (Guest)
on 2006-05-21 21:37
(Received via mailing list)
Kevin,

> create a directory called 'shared' in your view path.
>
> then call them as 'shared/partial1' and they should all go to the same place.

Thx a lot, i have been thinking about this too, just have been wondering
what's the standard way of doing it since something like this (AFAIK)
was not discussed in the AWDwR book. So thanks again.

Cheers,
Peter
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Kevin Olbrich (Guest)
on 2006-05-21 22:23
(Received via mailing list)
On Sunday, May 21, 2006, at 9:36 PM, Peter Szinek wrote:
>
>Cheers,
>Peter
>
>_______________________________________________
>Rails mailing list
>Rails@lists.rubyonrails.org
>http://lists.rubyonrails.org/mailman/listinfo/rails

If you look carefully, you will see that AWDwR does mention shared
partials.

_Kevin
This topic is locked and can not be replied to.