我正在尝试将我的rails 3应用程序迁移到rails 4版本。仅在rails 3版本中,devise gem的routes.rb文件中的下一代码正常工作,但相同的代码不适用于rails 4版本。
devise_for :users, :controllers => { :passwords => 'passwords'}
# devise_for :users, :controllers => { :invitations => 'invitations' }
devise_for :users
devise_for :users, :path => '', :path_names => {:sign_in => 'login', :sign_out => 'logout'}
devise_for :users do
get "/users/sign_out" => "devise/sessions#destroy", :as => :destroy_user_session
end
在rails 4版本中,我对上述代码的误差低于误差。
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/actionpack-4.0.0/lib/action
_dispatch/routing/route_set.rb:409:in `add_route': Invalid route name, already i
n use: 'new_user_session' (ArgumentError)
You may have defined two routes with the same name using the `:as` option, or yo
u may be overriding a route already defined by a resource with the same naming.
For the latter, you can restrict the routes created with `resources` as explaine
d here:
http://guides.rubyonrails.org/routing.html#restricting-the-routes-created