TL DR
Rails 3.1, Rails 4, Rails 5 and all that comes next
app/views/application
The engine automatically searches for this path if the view is not found in the controller path.
Rails 3 and earlier
app/views/shared
The engine is NOT looking for this path automatically.
Long story
Rails 3 (and the previous version) have a default location for storing general views.
Informal agreement - keep general views in application / views / general . In any case, if you saved them, you must specify the path
# render app/views/shared/menu.html.erb <%= render :partial => "shared/menu" %>
This offer has been popularized by Agile Web Development with Rails .
Rails 3.1 introduces the official < official standard for storing general views:
app / views / app
Thanks to this standard, the engine now automatically searches for patterns in the application / views / application. As a result, you no longer need to use the full path .
Those curious can follow this decision here.
Old syntax
# render app/views/application/menu.html.erb # unless menu.html.erb is found in appp/views/my_controller <%= render :partial => "menu" %>
New syntax
# render app/views/application/menu.html.erb # unless menu.html.erb is found in appp/views/my_controller <%= render partial: "menu" %>
Of course, you can still post your general views wherever you want, and refer to them along the way
<%= render :partial => "my_own_special_shared_folder/menu" %>
If you have no reason to do so, please adhere to the new standard and keep the general views in app/views/application .
Mihai-Andrei Dinculescu Feb 07 '16 at 14:30 2016-02-07 14:30
source share