I am using Ruby on Rails 3.0.7 and I am planning to use partial templates. All classes in my application would use same partials so I have to decide where to located all those.
Is it a good idea to put "global" shared partial templates in the lib
folder? If no, what is a common practice to choose the folder where to put those? Any advice on how to properly name and load that folder?
The standard is placing all shared partials in app/views/shared
, and referencing them as
render :partial => 'shared/partial_name'
If you have a standard "row in a list" partial (say, for an index page), you could use a shared partial like:
# To render a single object row:
render :partial => 'shared/item', :locals => { :item => @item }
# Or to render them all:
render :partial => 'shared/item', :collection => @items