如何定义路线

时间:2012-06-24 23:35:17

标签: ruby-on-rails-3 routes

在我的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'

我的错误是什么?

1 个答案:

答案 0 :(得分:0)

请尝试使用此功能:search_movie_path

相关问题