Saving data-exersise 5


i need help with this

So far we've been loading messages from the database and displaying them in the view. How can we create new messages and save them to the database? Looking at the seven standard Rails actions, we need to use the new and create actions. Let's set them up now.

In the routes file, create a route that maps requests to messages/new to the Message controller's new action.

Then in the Messages controller below the index action, add the new action:


I need the same help.


Did you ever figure this out? Also how did your code look for exercise 4?


I have figured step 1.Go to the file route.rb. in configure.
Under the other get message type this:
get '/messages/new' => get 'messages#new'.
On exercise four I had some trouble. I kept retyping what they had down but it wouldn't go.Finally the get code message came on and I hit that. It passes me through.
I have noticed with these programs that when I have the right code and in the questions and answers someone else had the same code ND just delete yours and copy and paste the one in the q&a. There's never any difference between mine and theirs. I don't know why that is.


it should be

get '/messages/new'=>'messages#new'


Finally got this thanks to your help. For some reason I was thinking it was post'messages/new'=>messages#create' but was wrong.

kentrg solution works.


it should look like this
get '/messages' => 'messages#index'
get 'messages/new' => 'messages#new'
post 'messages' => 'messages#create'


or something of the sort


it should look like this:

def index
@messages = Message.all

def new
	@message =


2 posts were split to a new topic: Need Help on Exercise 5


This topic is inactive.