Hi, I’m having issues with the lesson Saving Data at step 2. My /app/controllers/messages_controller.rb looks like the following:
class MessagesController < ApplicationController
def index
@messages = Message.all
end
def new
@messages = Message.new
end
end
What am I doing wrong? The Error I recieve is:
In the ‘new’ action did you save a new Message object into the @message variable?
HI this part
def new
@messages = Message.new
end
this line
@messages = Message.new
you wrote @messages instea of @message
Thanks, yes that seemed to be the issue, however why did it work then having the:
def index
@messages = Message.all
end
From the earlier lessons.
they are different variable in one you saved all the Messsage @messages
@messages = Message.all
in the other you saved the new massage @message
@message = Message.new
1 Like
zystvan
Closed
5
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.