我正在開發rails應用程序並遇到此類問題。Rails路由配置認爲操作方法是對象ID
我有movies_controller.rb
,在那裏我有這些動作和路線定義:
Prefix Verb URI Pattern Controller#Action
movies GET /movies(.:format) movies#index
POST /movies(.:format) movies#create
new_movie GET /movies/new(.:format) movies#new
edit_movie GET /movies/:id/edit(.:format) movies#edit
movie GET /movies/:id(.:format) movies#show
PATCH /movies/:id(.:format) movies#update
PUT /movies/:id(.:format) movies#update
DELETE /movies/:id(.:format) movies#destroy
root GET / redirect(301, /movies)
movies_by_director GET /movies/by_director(.:format) movies#by_director
但是當我嘗試去/movies/by_director?director="something"
,導軌想,我導航到movies#show
行動參數:id = by_director
。
我在做什麼錯?
它在行動。 :) 謝謝! –