5/7 step 2


#1

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?


#2

HI this part

  def new
    @messages = Message.new
  end

this line

@messages = Message.new

you wrote @messages instea of @message


#3

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.


#4

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

#5

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.