2012-06-11 60 views
-1

我正在使用Rails,iOS和設計。我想讀一個用戶。路徑將是users /:id。如何創建用戶使用設計閱讀?

我得到以下錯誤:

Started GET "https://stackoverflow.com/users/0" for 127.0.0.1 at 2012-06-11 17:37:50 -0600 
Processing by UsersController#show as JSON 
    Parameters: {"id"=>"0"} 
[Devise] Could not find devise mapping for path "https://stackoverflow.com/users/0". 
Maybe you forgot to wrap your route inside the scope block? For example: 

devise_scope :user do 
    match "/some/route" => "some_devise_controller" 
end 

Completed 500 Internal Server Error in 0ms 

AbstractController::ActionNotFound (Could not find devise mapping for path "https://stackoverflow.com/users/0". 
Maybe you forgot to wrap your route inside the scope block? For example: 

devise_scope :user do 
    match "/some/route" => "some_devise_controller" 
end 

我試圖把資源:用戶devise_for下:用戶以及獲得「用戶/:id爲」 =>「用戶#秀」和匹配「用戶/:id「=>」users#show「。

任何想法?

回答

1

這是我的最終解決方案:

devise_for :users, :controllers => { :registrations => "users"} 

devise_scope :user do 
    get "users/:id" => "users#show" 
end 
0

查覈在所謂的「配置路由」的文檔的部分:

https://github.com/plataformatec/devise#readme

答案也部分包含在錯誤消息。

至於爲什麼devise_for似乎王牌在routes.rb該行以下路線,檢查出的指南:

http://guides.rubyonrails.org/routing.html#crud-verbs-and-actions

Rails routes are matched in the order they are specified, so if you have a resources :photos above a get 'photos/poll' the show action’s route for the resources line will be matched before the get line. To fix this, move the get line above the resources line so that it is matched first.