-1

I'm using Rails, iOS, and devise. I want to read a single user. The path would be users/:id.

I get the following error:

Started GET "/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 "/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 "/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

I've tried putting resources :users underneath devise_for :users as well as get "users/:id" => "users#show" and match "users/:id" => "users#show".

Any ideas?

4

2 回答 2

1

这是我的最终解决方案:

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

devise_scope :user do
  get "users/:id" => "users#show"
end
于 2012-06-15T14:57:08.260 回答
0

查看文档中名为“配置路由”的部分:

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

答案也部分包含在错误消息中。

至于为什么 devise_for 似乎胜过该行下方的路线routes.rb,请查看指南:

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

Rails 路由按照指定的顺序进行匹配,因此如果您在 get 'photos/poll' 上方有一个资源 :photos,则资源行的 show action 路由将在 get 行之前匹配。要解决此问题,请将 get 行移到资源行上方,以便首先匹配。

于 2012-06-11T23:59:35.800 回答