# A place to put common partial templates and RJS files?

**URL:** <https://www.ruby-forum.com/t/a-place-to-put-common-partial-templates-and-rjs-files/88847>\
**Category:** Rails\
**Created:** [March 14, 2007, 11:42pm UTC](https://www.ruby-forum.com/t/a-place-to-put-common-partial-templates-and-rjs-files/88847 "2007-03-14T23:42:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PSSS\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/fbc32d/32.png) [@PSSS\_S](https://www.ruby-forum.com/u/PSSS_S)\
**Post date:** [March 14, 2007, 11:42pm UTC](https://www.ruby-forum.com/t/a-place-to-put-common-partial-templates-and-rjs-files/88847/1 "2007-03-14T23:42:35Z")

</div>

Greetings,

I have a partial template file (acutally, it is an RJS file but the  
same principle is in question here) which I wish to “share” between  
multiple controllers. Does anyone know where in the directory tree I  
would put these files in order that I can access them from multiple  
controllers in the same app? I really would prefer not having to copy  
them all into all of the directories. I guess what I am looking for is  
a “mixin” type thing for views. I tried putting them in a directory  
called “application” under views, but that didn’t work.

Thanks in advance,

Peter

---

<div class="post-metadata">

**Author:** ![PSSS\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/fbc32d/32.png) [@PSSS\_S](https://www.ruby-forum.com/u/PSSS_S)\
**Post date:** [March 14, 2007, 11:46pm UTC](https://www.ruby-forum.com/t/a-place-to-put-common-partial-templates-and-rjs-files/88847/2 "2007-03-14T23:46:36Z")

</div>

P² [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have a partial template file (acutally, it is an RJS file but the  
> same principle is in question here) which I wish to “share” between  
> multiple controllers. Does anyone know where in the directory tree I  
> would put these files in order that I can access them from multiple  
> controllers in the same app?

I stick them in a “shared” folder, then call out to them like this:

render :partial =\> “shared/sort\_div\_tag”

Cheers,  
Tyler

---

<div class="post-metadata">

**Author:** ![PSSS\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/fbc32d/32.png) [@PSSS\_S](https://www.ruby-forum.com/u/PSSS_S)\
**Post date:** [March 14, 2007, 11:54pm UTC](https://www.ruby-forum.com/t/a-place-to-put-common-partial-templates-and-rjs-files/88847/3 "2007-03-14T23:54:37Z")

</div>

On Wed, Mar 14, 2007 at 10:40:48PM -0000, P² wrote :

> I guess what I am looking for is  
> a “mixin” type thing for views. I tried putting them in a directory  
> called “application” under views, but that didn’t work.

I put my shared views rjs/templates in app/view/shared/

For instance:

render :partial =\> ‘shared/my\_partial’  
render :file =\> ‘shared/my\_file.rtex’

For other snippets, put them in lib/\* and add a ‘require your\_file’ at  
the beginning of your controller, or, if you’re playing with modules,  
‘include my\_module’ after the beginning of your ApplicationController.

++

–  
,========================.  
| Pierre-Alexandre M. |  
| email : removed\_email\_address@domain.invalid |  
`========================’

---

<div class="post-metadata">

**Author:** ![PSSS\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/fbc32d/32.png) [@PSSS\_S](https://www.ruby-forum.com/u/PSSS_S)\
**Post date:** [March 15, 2007, 12:10am UTC](https://www.ruby-forum.com/t/a-place-to-put-common-partial-templates-and-rjs-files/88847/4 "2007-03-15T00:10:39Z")

</div>

On Wed, Mar 14, 2007 at 03:45:18PM -0700, Tyler MacDonald wrote :

> I stick them in a “shared” folder, then call out to them like this:
> 
> render :partial =\> “shared/sort\_div\_tag”

You’re definitively faster than me, Tyler 🙂

–  
,========================.  
| Pierre-Alexandre M. |  
| email : removed\_email\_address@domain.invalid |  
`========================’
