Advanced Rails Recipes 书中21页,search那一段
访问 http://localhost:3000/events/search?q=rubyconf
ActiveRecord::RecordNotFound in EventsController#show
Couldn't find Event with ID=search
RAILS_ROOT: C:/rubydev/ad/REST
Application Trace | Framework Trace | Full Trace
D:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1379:in find_one'
find_from_ids'
D:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1362:in
D:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:537:in find'
show'
app/controllers/events_controller.rb:16:in
D:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1379:in find_one'
find_from_ids'
D:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1362:in
D:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:537:in find'
send'
D:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:1162:in
D:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/base.rb:1162:in `perform_action_without_filters'
......................
.......................
............................
........................
Request
Parameters:
{"id"=>"search",
"q"=>"rubyconf"}
Show session dump
flash: !map:ActionController::Flash::FlashHash {}
Response
Headers:
{"cookie"=>[],
"Cache-Control"=>"no-cache"}
出现这个错误,是因为routes.rb配置的问题。
这个配置了吗?
[code="ruby"]map.resources :events, :collection => { :search => :get }[/code]
如果配置了,将routes.rb贴出来看看。
或者使用
[code="ruby"]rake routes[/code]
自己看下当前的routes.