Kyle Macey
Kyle Macey

Reputation: 8154

Universal partial?

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!

Upvotes: 0

Views: 197

Answers (2)

apneadiving
apneadiving

Reputation: 115511

Yes you can:

<%= render "partial_folder/partial_name" %>

Example:

<%= render "layouts/sidebar" %>

Upvotes: 1

Sebastian Martinez
Sebastian Martinez

Reputation: 447

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.

Upvotes: 3

Related Questions