I am using Ruby on Rails Tutorial by Michael Hartl - Chapter 8 - Rails 3 I use rails 3.1 In the file new.html.erb I have:
<h1>Sign up</h1>
<%= form_for(@user) do |f| %>
<%= render 'shared/error_messages' %>
Trying to visit http://localhost:3000/signup, it gives me the following message:
ActionView::MissingTemplate in Users#new
Missing partial /shared/error_messages with {:handlers=>[:erb, :builder, :coffee],
:formats=>[:html], :locale=>[:en, :en]}. Searched in:
* "/Users/macbook/rails_projects/sample_app/app/views"
I have googled around but could not find this answer. The same question was posted a while ago at: Ruby Chapter 8 tutorial partial file not found
What I tried: -putting a / in front of shared - putting :partial => after render -putting :target => @user
If I don't put it into the shared folder, it works. Is there a different way to do this in rails 3.1.3? Please let me know because I've spent so much time trying to figure it out.
If you say;
<%= render 'shared/error_messages' %>
it will look for a partial named shared/error_messages
in the app/views/#{controller_name}
ie. if you're in the users#signup
action, it will expect to find app/views/users/shared/error_messages
If in fact you mean app/views/shared/error_messages
then you should say the following.
<%= render '/shared/error_messages' %>
That's just the only way to avoid ambiguity.
Did you name the file correctly (with the underscore)? That was my problem...
error_messages.html.erb
should be
_error_messages.html.erb
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With