在我的routes.rb
文件中,我已将成员添加到电影资源:
resources :movies do
get 'search', :on => :member
end
所以我有这个路线列表:
search_movie GET /movies/:id/search(.:format) {:action=>"search", :controller=>"movies"}
movies GET /movies(.:format) {:action=>"index", :controller=>"movies"}
POST /movies(.:format) {:action=>"create", :controller=>"movies"}
new_movie GET /movies/new(.:format) {:action=>"new", :controller=>"movies"}
edit_movie GET /movies/:id/edit(.:format) {:action=>"edit", :controller=>"movies"}
movie GET /movies/:id(.:format) {:action=>"show", :controller=>"movies"}
PUT /movies/:id(.:format) {:action=>"update", :controller=>"movies"}
DELETE /movies/:id(.:format) {:action=>"destroy", :controller=>"movies"}
我希望在我看来使用这条路线如下:
= link_to 'Find Movies With Same Director', search_path(@movie)
但它出现了错误:
undefined local variable or method `search_path'
我的错误是什么?