Where to put partials shared by the whole application in Rails?
The Rails convention is to put shared partials in /app/views/shared
.
Update
Layout inheritance is now in the guides under layout and rendering Template inheritance works similarly.
Rails 3.1 and following versions implement template inheritance, so I think the correct place for shared partials is now /app/views/application/
, say you are in products#index
you can do the following:
-# products#index
= render @products.presence || 'empty'
-# /app/views/application/_empty.html.haml
There are no items
btw it's application
because the connection is the controller inheritance, so this assumes ProductsController < ApplicationController
This way if you implement /app/views/products/_empty.html.haml
that will be taken, the above is a fallback for all the missing partials, and I can't check right now, but I think even for the template itself...
Railscast: template inheritance!