Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

a rails partial but used by multiple views

I have a piece of code that I would like to have show up on several areas... from two different views. Which is to say handled by two different controllers (all the data comes from a helper though) what is the best way to break this up, should these partials be rendered then as lay outs? Though they use the twitter bootstrap modal and I have had huge issues getting those to show correctly when called from a layout (most the reason why I have to break up this code into a partial, one that comes from one index.erb.html and another that comes from a partial of its own _document_header.erb.html good time to ask, can you stuff one partial within another...

so just trying to get some pointers. This code is really common to two views. (and is not always needing to be rendered or displayed)...so want to do this the best way.

like image 870
Codejoy Avatar asked Feb 18 '23 15:02

Codejoy


1 Answers

You can reference a partial that is anywhere in your views folder.

It's common to make a "shared" folder in your views and reference the partial like: <%= render 'shared/my_partial' %>

like image 126
trvsdnn Avatar answered Feb 28 '23 07:02

trvsdnn