views:

56

answers:

3

Where would I go about placing partial files shared by more than one model? I have a page called crop.html.erb that is used for one model - Photo. Now I would like to use it for another model called User as well.

I could copy and paste the code but that's not very DRY, so I figured I would move it into a partial.

Since it's shared between two models - where would I place that partial?

Thanks!

+1  A: 

I general have a shared folder in my views that contains commonly used partials.

Toby Hede
Thank you for your answer.
yuval
+1  A: 

It doesn't matter where you put them. You can render any partial at any arbitrary location by providing the file's path to render - it doesn't need to be associated with the controller that's rendering it. I use a directory simply called partials under the view directory, and call partials in it like this:

render :partial => 'partials/mypartial'
Jimmy Cuadra
oh I'm well aware. I was interested in the best practice. Thanks, though!
yuval
+4  A: 

The Rails convention is to put shared partials in /app/views/shared.

John Topley
Yep, this is what DHH and Obie Fernandez would like to see in our code
baijiu
+1 for `shared` folder
Simone Carletti
thank you very much!
yuval