开发者

Universal partial?

开发者 https://www.devze.com 2023-02-24 00:09 出处:网络
I made a partial for a site and my client loved it. It was basically just a sidebar that helps browse the database. Now he wants the sidebar all throughout the site on various pages. So, how can I cal

I made a partial for a site and my client loved it. It was basically just a sidebar that helps browse the database. Now he wants the sidebar all throughout the site on various pages. So, how can I call a partial from any controller without having to开发者_开发百科 copy and paste the file into each directory.

Thanks in advance!


You could try placing your partial in a folder call shared inside app/views and doing something like:

render :partial => 'shared/sidebar'

where you want to render the partial.


Yes you can:

<%= render "partial_folder/partial_name" %>

Example:

<%= render "layouts/sidebar" %>
0

精彩评论

暂无评论...
验证码 换一张
取 消