在我的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'
我的错误是什么?
答案 0 :(得分:0)
请尝试使用此功能:search_movie_path