关于Rails 3.0.9 Ruby 1.9.2 p180 Devise:Rails 3.0.9 Ruby 1.9.2 p180 Devise-路线

 2021-04-09 

Rails 3.0.9 + Ruby 1.9.2 p180 + Devise - Routes

我正在使用Rails 3.0.9 Ruby 1.9.2 p180 Devise,这是我的路线:

1
2
3
4
[...]
devise_for :users,:controllers => { :sessions =>"users/sessions" }
[...]
root :to =>"users/sessions#new"

我基本上想使devise登录页面成为我的根路由...但是当我尝试将其作为本地服务器(http:// localhost:3000)时,出现以下错误:

1
2
3
4
5
Unknown action

Could not find devise mapping for path"/". Maybe you forgot to wrap your route inside
the scope block? For example: devise_scope :user do match"/some/route" =>
"some_devise_controller" end

尝试一下:

1
2
3
devise_scope :user do
  root :to =>"users/sessions#new"
end

编辑:
如果您使用的是devise的默认控制器,则可以执行以下操作:

1
2
3
devise_scope :user do
  root :to =>"devise/sessions#new"
end