5. Saving Data/Create messages


#1

Hello all :slightly_smiling_face:
I’m on this lesson: https://www.codecademy.com/courses/learn-rails/lessons/one-model/exercises/one-model-create-messages-i?action=lesson_resume&link_content_target=interstitial_lesson
!

Could you explain me why we create a second method before making the create one, and what is the ‘.save’ method in the second picture & the ‘render new’: (when message.save can be false ?)
image|262x273

image

Thanks a lot :slight_smile:


#2

Hi @cloudblaster15402,

The new action is to give you a view where there will be a form to submit data through, and the create action’s purpose is to accept and process that data.

The first line in the create action creates a new message to be created with the data you just submitted:

@message = Message.new(message_params)

Then, the if statement checks if the message actually did get saved, or if there were errors saving it.


#3

Thanks I understand better :+1: (and subscribed to the pro option for the chat with mentors)


#4

This topic is solved.