Hi there !
I’m currently facing the same problem as yourself, I haven’t fixed yet, even though you have placed the solution right there.
I think your solution isn’t completely Rails 3…
This code appears to be the Rails 2 way to do it…
Shovell::Application.routes.draw do
get "votes/create"
#match ':controller(/:action(/:id(.:format)))'
resources :stories, :has_many => :votes
#map.resources :stories
get "stories/index"
To get the correct routes this code should be used instead in Rails 3
resources :stories do
resources :votes
end
that will actually give us the correct routes when using rake routes
stories_index GET /stories/index(.:format) {:controller=>“stories”, :action=>“index”}
votes_create GET /votes/create(.:format) {:controller=>“votes”, :action=>“create”}
story_votes GET /stories/:story_id/votes(.:format) {:action=>“index”, :controller=>“votes”}
POST /stories/:story_id/votes(.:format) {:action=>“create”, :controller=>“votes”}
new_story_vote GET /stories/:story_id/votes/new(.:format) {:action=>“new”, :controller=>“votes”}
edit_story_vote GET /stories/:story_id/votes/:id/edit(.:format) {:action=>“edit”, :controller=>“votes”}
story_vote GET /stories/:story_id/votes/:id(.:format) {:action=>“show”, :controller=>“votes”}
PUT /stories/:story_id/votes/:id(.:format) {:action=>“update”, :controller=>“votes”}
DELETE /stories/:story_id/votes/:id(.:format) {:action=>“destroy”, :controller=>“votes”}
stories GET /stories(.:format) {:action=>“index”, :controller=>“stories”}
POST /stories(.:format) {:action=>“create”, :controller=>“stories”}
new_story GET /stories/new(.:format) {:action=>“new”, :controller=>“stories”}
edit_story GET /stories/:id/edit(.:format) {:action=>“edit”, :controller=>“stories”}
story GET /stories/:id(.:format) {:action=>“show”, :controller=>“stories”}
PUT /stories/:id(.:format) {:action=>“update”, :controller=>“stories”}
DELETE /stories/:id(.:format) {:action=>“destroy”, :controller=>“stories”}
However this form syntax you suggested is still problematic to me:
<div id="vote_form">
<% form_tag :url => story_votes_path(@story), :remote => true do %>
<%= submit_tag 'shove it' %>
<% end %>
</div>
When I click on the button for that Ajax Action it output the following error on the Browser:
No route matches “/stories/7-another-story”
Do you happen to know what could possibly be wrong ?
Please help me,
Best Regards,
Jose.