我认为我的设置并不太复杂,我有一些带有RSVP的事件。我的路线文件有
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
哪个给我一个佣金路线
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"}
然后我有一个
<%= link_to 'List Attending', list_event_rsvps_path(event) %>
但是当我点击这个视图时,我得到了
未知行动
没有任何行动回应展示。动作:create,current_admin, current_admin =,destroy,index,list,new,sign_in,sign_out,和 signed_in?
服务器日志显示
处理RsvpsController #show(2014.01-10 16:12:18为127.0.0.1) [GET]参数:{“id”=&gt;“list”,“event_id”=&gt;“1”}
ActionController :: UnknownAction(没有动作响应show。动作: create,current_admin,current_admin =,destroy,index,list,new, sign_in,sign_out和signed_in?):
c:/Ruby187/lib/ruby/1.8/webrick/httpserver.rb:104:在service'
运行中' c:/Ruby187/lib/ruby/1.8/webrick/server.rb:173:在
c:/Ruby187/lib/ruby/1.8/webrick/httpserver.rb:65:instart_thread'
开始' c:/Ruby187/lib/ruby/1.8/webrick/server.rb:162:in
c:/Ruby187/lib/ruby/1.8/webrick/server.rb:162:instart_thread'
开始'
c:/Ruby187/lib/ruby/1.8/webrick/server.rb:95:in
c:/Ruby187/lib/ruby/1.8/webrick/server.rb:92:ineach'
start'
c:/Ruby187/lib/ruby/1.8/webrick/server.rb:92:in
c:/Ruby187/lib/ruby/1.8/webrick/server.rb:23:instart'
start'
c:/Ruby187/lib/ruby/1.8/webrick/server.rb:82:in
此时我已经尝试了有关该主题的所有内容。我正在使用ruby 1.8.7和Rail 2.3.18,因为我的网络主机仍在使用它。我不知道为什么当我从控制器和所有路线中删除它时,它仍在寻找show动作。
答案 0 :(得分:1)
路线按照定义的顺序应用。试试看:
map.resources :events, :has_many => :rsvps
低于其他路线。