Saving data-exersise 5


#1

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:


#2

I need the same help.


#3

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


#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.


#5

it should be

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


#6

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.


#7

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


#8

or something of the sort


#9

it should look like this:

def index
@messages = Message.all
end

def new
	@message = Message.new
end

#10

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


#11

This topic is inactive.


#12