A place to put common partial templates and RJS files?

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

[email protected] 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

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 : [email protected] |
`========================’

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 :slight_smile:


,========================.
| Pierre-Alexandre M. |
| email : [email protected] |
`========================’

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs