This error states that your application has tried to search for a partial _messages.html.erb, as a result of this the partial must not be in your /app/views/messages
which results in the message you are being shown. Check your messages
directory and check if you have this partial. Going by your nested resources I am guessing your association between Load
and Message
is:
class Load < ActiveRecord::Base
has_many :messages
end
class Message < ActiveRecord::Base
belongs_to :load
end
Further more I noticed that you have the following line in your index
action: @message = load.messages.new
surely this does not seem right. Because what your telling your application to do is when the controller recieves a response to render the index
action it should also create message by doing @message = load.messages.new
which is why it is trying to render the partial.
To clarify things a bit more for you. If in your application you had a link_to
to create a new user. Upon clicking the new user it will do something like:
def new
@user = User.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @user }
end
end
And will render `app/views/users/new.html.erb which inside this will most probably have a
<%= form_for @user do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<% end %>
This will call your partial which in normal cases would be _form.html.erb
. The create action of a particular controller will come into play when you attempt to save the partial. Usually a create
block for a controller will look like this:
def create
@title = "Create a user"
@user = User.new(params[:user])
if @user.save
redirect_to usermanagement_path
flash[:success] = "Created successfully."
else
@title = "Create a user"
render 'new'
end
end
Here inside the create
action when your _form.html.erb
or _message.html.erb
is submitted it will try to create a new user by passing in the user through the params
. I do thoroughly believe that your issue may potentially well be:
1) Your missing your _message.html.erb
2) Also you are calling a .new
inside your index
action.
Hope this clears this up for you.