林有一個問題是關於我的路線。使用im設計,但我也有定製的控制器,以允許管理員編輯用戶設置。RoutingError(無路由匹配[PUT]
對我來說,一切工作在發展精細但是當我部署到我的託管服務器的東西不工作,因爲他們應該。
問題我有如下,當一個管理更新用戶,我得到一個路由錯誤。這工作正常本地,但在託管服務器上我得到以下
Started PUT "https://stackoverflow.com/users/4" at Fri Feb 21 04:08:14 -0500 2014
ActionController::RoutingError (No route matches [PUT] "/4"):
actionpack (3.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'> actionpack (3.2.2) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.2) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.2) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/request_id.rb:22:in `call'
什麼不能t看起來對我來說,「/ users/4」是如何被降低到「/ 4」的。剩下的路徑發生了什麼?
我的路線看起來很好
users POST /users(.:format) users/registrations#create
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) users/registrations#cancel
user_registration POST /users(.:format) users/registrations#create
new_user_registration GET /users/sign_up(.:format) users/registrations#new
edit_user_registration GET /users/edit(.:format) users/registrations#edit
PUT /users(.:format) users/registrations#update
DELETE /users(.:format) users/registrations#destroy
new_user_session GET /users/sign_in(.:format) devise/sessions#new
POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
POST /users/password(.:format) devise/passwords#create
GET /users/password/new(.:format) devise/passwords#new
GET /users/password/edit(.:format) devise/passwords#edit
PUT /users/password(.:format) devise/passwords#update
GET /users/cancel(.:format) devise/registrations#cancel
POST /users(.:format) devise/registrations#create
GET /users/sign_up(.:format) devise/registrations#new
GET /users/edit(.:format) devise/registrations#edit
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
正如你可以看到用戶更新路徑存在
PUT /users/:id(.:format)用戶#更新
主機服務器使用乘客,導軌3.2.X,紅寶石1.8.7。我知道3.2.x版存在安全問題,但這只是我的一個愛好。
路由配置
resources :comm_channels
devise_for :users, :controllers => { :registrations => "users/registrations" } do
post '/users', :to => 'users/registrations#create'
end
devise_for :users
resources :users,:roles,:news ,:invites, :clubs, :events, :albums, :pictures, :static_pages, :sponsors
match "static_pages/:action/:pagetype", :controller => "static_pages"
match 'invites/edit(/:eid/:iid/:code)' => 'invites#edit', :as => :invite_confirm
match 'events/:id/reminder' => 'events#reminder', :as => :event_reminder
match 'events/:id/republish' => 'events#republish', :as => :event_republish
match 'roles/resetMembership' => 'roles#resetMembership', :as => :reset_membership
match 'roles/membership_reminder' => 'roles#membership_reminder', :as => :membership_reminder
root :to => "static_pages#show#home"
更新2
登上香港專業教育學院採取蒂姆斯的意見和清理我的文件航線不過IM仍然能看到同樣的問題。
我的路線,如今看起來像
resources :comm_channels
devise_for :users,:path => 'club_users', :controllers => { :registrations => "users/registrations" } do
post '/users', :to => 'users/registrations#create'
end
resources :users
resources :roles,:news ,:invites, :clubs, :events, :albums, :pictures, :static_pages, :sponsors
match "static_pages/:action/:pagetype", :controller => "static_pages"
match 'invites/edit(/:eid/:iid/:code)' => 'invites#edit', :as => :invite_confirm
match 'events/:id/reminder' => 'events#reminder', :as => :event_reminder
match 'events/:id/republish' => 'events#republish', :as => :event_republish
match 'roles/resetMembership' => 'roles#resetMembership', :as => :reset_membership
match 'roles/membership_reminder' => 'roles#membership_reminder', :as => :membership_reminder
root :to => "static_pages#show#home"
路線輸出如下
users POST /users(.:format) users/registrations#create
new_user_session GET /club_users/sign_in(.:format) devise/sessions#new
user_session POST /club_users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /club_users/sign_out(.:format) devise/sessions#destroy
user_password POST /club_users/password(.:format) devise/passwords#create
new_user_password GET /club_users/password/new(.:format) devise/passwords#new
edit_user_password GET /club_users/password/edit(.:format) devise/passwords#edit
PUT /club_users/password(.:format) devise/passwords#update
cancel_user_registration GET /club_users/cancel(.:format) users/registrations#cancel
user_registration POST /club_users(.:format) users/registrations#create
new_user_registration GET /club_users/sign_up(.:format) users/registrations#new
edit_user_registration GET /club_users/edit(.:format) users/registrations#edit
PUT /club_users(.:format) users/registrations#update
DELETE /club_users(.:format) users/registrations#destroy
GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
我仍然看到在產品設置了同樣的錯誤。
Started PUT "https://stackoverflow.com/users/21" for 194.XXXX at Sun May 11 08:05:48 -0400 2014
ActionController::RoutingError (No route matches [PUT] "/21"):
actionpack (3.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.2) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.2) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.2) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/static.rb:61:in `call'
香港專業教育學院嘗試不同的也是最簡單的變化e.g
devise_for :users,:path => 'club_users'
resources :users
而且還逆向
devise_for :users
resources :users, :path => 'useradmin'
沒有喜悅。正如我耙路線之前說的告訴我它有
PUT /users/:id(.:format) users#update
但某處沿線,PUT「/用戶/ 21」被剝離下來「/ 21」。
任何想法?
請添加您的/config/routes.rb – krabbi
路線已被添加。 – JBOnThePc
嗯,我沒有線索,我不記得我曾經遇到過這種行爲。也許別人有任何想法。請檢查它是否出現在其他路線上,或者只是「放置用戶」。在本地你運行webrick或瘦或類似的東西? – krabbi