0
votes

My setup isn't too complex I think, I have an Event with some RSVPs. My routes file has

map.resources :events, :has_many => :rsvps
map.resources :rsvps, :only => [:new, :create, :destroy, :index], :collection => { :list => :get }
 map.resources :events do |event|
event.resources :rsvps, :only => [:new, :create, :destroy, :index], :collection => { :list => :get }
      end

Which give me a rake routes

                    event_rsvps GET    /events/:event_id/rsvps(.:format)               {:action=>"index", :controller=>"rsvps"}
                                 POST   /events/:event_id/rsvps(.:format)               {:action=>"create", :controller=>"rsvps"}
                  new_event_rsvp GET    /events/:event_id/rsvps/new(.:format)           {:action=>"new", :controller=>"rsvps"}
                 edit_event_rsvp GET    /events/:event_id/rsvps/:id/edit(.:format)      {:action=>"edit", :controller=>"rsvps"}
                      event_rsvp GET    /events/:event_id/rsvps/:id(.:format)           {:action=>"show", :controller=>"rsvps"}
                                 PUT    /events/:event_id/rsvps/:id(.:format)           {:action=>"update", :controller=>"rsvps"}
                                 DELETE /events/:event_id/rsvps/:id(.:format)           {:action=>"destroy", :controller=>"rsvps"}
                          events GET    /events(.:format)                               {:action=>"index", :controller=>"events"}
                                 POST   /events(.:format)                               {:action=>"create", :controller=>"events"}
                       new_event GET    /events/new(.:format)                           {:action=>"new", :controller=>"events"}
                      edit_event GET    /events/:id/edit(.:format)                      {:action=>"edit", :controller=>"events"}
                           event GET    /events/:id(.:format)                           {:action=>"show", :controller=>"events"}
                                 PUT    /events/:id(.:format)                           {:action=>"update", :controller=>"events"}
                                 DELETE /events/:id(.:format)                           {:action=>"destroy", :controller=>"events"}
                      list_rsvps GET    /rsvps/list(.:format)                           {:action=>"list", :controller=>"rsvps"}
                           rsvps GET    /rsvps(.:format)                                {:action=>"index", :controller=>"rsvps"}
                                 POST   /rsvps(.:format)                                {:action=>"create", :controller=>"rsvps"}
                        new_rsvp GET    /rsvps/new(.:format)                            {:action=>"new", :controller=>"rsvps"}
                            rsvp DELETE /rsvps/:id(.:format)                            {:action=>"destroy", :controller=>"rsvps"}
                list_event_rsvps GET    /events/:event_id/rsvps/list(.:format)          {:action=>"list", :controller=>"rsvps"}
                                 GET    /events/:event_id/rsvps(.:format)               {:action=>"index", :controller=>"rsvps"}
                                 POST   /events/:event_id/rsvps(.:format)               {:action=>"create", :controller=>"rsvps"}
                                 GET    /events/:event_id/rsvps/new(.:format)           {:action=>"new", :controller=>"rsvps"}
                                 DELETE /events/:event_id/rsvps/:id(.:format)           {:action=>"destroy", :controller=>"rsvps"}
                                 GET    /events(.:format)                               {:action=>"index", :controller=>"events"}
                                 POST   /events(.:format)                               {:action=>"create", :controller=>"events"}
                                 GET    /events/new(.:format)                           {:action=>"new", :controller=>"events"}
                                 GET    /events/:id/edit(.:format)                      {:action=>"edit", :controller=>"events"}
                                 GET    /events/:id(.:format)                           {:action=>"show", :controller=>"events"}
                                 PUT    /events/:id(.:format)                           {:action=>"update", :controller=>"events"}
                                 DELETE /events/:id(.:format)                           {:action=>"destroy", :controller=>"events"}

I then have a

<%= link_to 'List Attending', list_event_rsvps_path(event) %> 

But when I click this view I get

Unknown action

No action responded to show. Actions: create, current_admin, current_admin=, destroy, index, list, new, sign_in, sign_out, and signed_in?

the server log shows

Processing RsvpsController#show (for 127.0.0.1 at 2014-01-10 16:12:18) [GET] Parameters: {"id"=>"list", "event_id"=>"1"}

ActionController::UnknownAction (No action responded to show. Actions: create, current_admin, current_admin=, destroy, index, list, new, sign_in, sign_out, and signed_in?):
c:/Ruby187/lib/ruby/1.8/webrick/httpserver.rb:104:in service'
c:/Ruby187/lib/ruby/1.8/webrick/httpserver.rb:65:in
run'
c:/Ruby187/lib/ruby/1.8/webrick/server.rb:173:in start_thread'
c:/Ruby187/lib/ruby/1.8/webrick/server.rb:162:in
start'
c:/Ruby187/lib/ruby/1.8/webrick/server.rb:162:in start_thread'
c:/Ruby187/lib/ruby/1.8/webrick/server.rb:95:in
start'
c:/Ruby187/lib/ruby/1.8/webrick/server.rb:92:in each'
c:/Ruby187/lib/ruby/1.8/webrick/server.rb:92:in
start'
c:/Ruby187/lib/ruby/1.8/webrick/server.rb:23:in start'
c:/Ruby187/lib/ruby/1.8/webrick/server.rb:82:in
start'

At this point I've tried everything I could find about the subject. I'm using ruby 1.8.7 and Rail 2.3.18 since my web host is using that still. I have no clue why it's still looking for the show action when I've removed it from the controller and all the routes.

1

1 Answers

1
votes

The routes are applied in the order they are defined. Try putting:

map.resources :events, :has_many => :rsvps

Below the other routes.