Reputation: 4963
So I made a quick ruby on rails app (railstutorial twitter clone). My source code is the same as https://github.com/railstutorial/sample_app_2nd_ed.
Then I tried adding replies to the messages with http://railscasts.com/episodes/262-trees-with-ancestry?view=asciicast. My comment is at the bottom BigBoy1337. This is what it says:
I keep getting an error saying
undefined method `new_message_path'
This is in app/views/messages/_messages.html.erb
for
<%= link_to "Reply", new_message_path(:parent_id => message) %>
<% if current_user?(message.user) %>
<%= link_to "delete", message, method: :delete,
confirm: "You sure?",
title: message.content %>
<% end %>
Any idea where to define new_message_path? I tried adding
def new_message_path
end
in app/controllers/message/controllers
...but it didn't work. I have downloaded the source code (https://github.com/BigBoy1337/railscasts-episodes/tree/master/episode-262/messenger-after) and that works! but I cant find where they define new_message_path, yet it works. Why does it work for them, and how can I get it to work for me?
Upvotes: 1
Views: 174
Reputation: 22258
new_message_path
is defined in routes.rb
.
Look for this line:
resources :messages
read this to learn about rails routing.
Upvotes: 1
Reputation: 8154
That's a resource route. Try adding the following to routes.rb:
resources :messages
Also, read this: http://guides.rubyonrails.org/routing.html
Upvotes: 1