作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在设计中自定义我的路线。我尝试使用 devise_scope :user,但它不起作用。所以我改为 devise_for,并跳过了自定义路由(注册、确认、密码、 session )并且它起作用了。但是,例如,当我调用“session_path”时,我的 View 中会出现错误。它正在制作一个重定向到“session.user”的表单,这是没有意义的。
这是代码:
#routes.rb devise_for :users, :path => '', :skip => [ :passwords, :registrations, :confirmations] do post "account/password", :to => "devise/passwords#create" get "account/password/new", :to => "devise/passwords#new", :as => "new_password" get "account/password/edit", :to => "devise/passwords#edit", :as => "edit_password" put "account/password", :to => "devise/passwords#update" post "account", :to => "users/registrations#create" get "sign_up", :to => "users/registrations#new" delete "account", :to => "users/registrations#destroy" post "confirmation", :to => "devise/confirmations#create" get "confirmation/new", :to => "devise/confirmations#new", :as => "new_confirmation" get "confirmation", :to => "devise/confirmations#show" end
新 session View :
#users/sessions/new.html.erb = form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
错误:
No route matches {:action=>"new", :format=>:user, :controller=>"devise/passwords"}
我该怎么办? “devise_scope”发生了什么无法正常工作(它显示的错误是“无法找到...的设计映射”)?
谢谢
最佳答案
正在生成哪些路由?运行 rake 路线来找出答案。
如果您没有看到所需的路由,请尝试在 devise_for 语句之后的 as block 上定义自定义路由。比如
devise_for :users, skip => [ :passwords, :registrations, :confirmations]
as :user do
post "account/password" => "devise/passwords#create"
get "account/password/new" => "devise/passwords#new"
get "account/password/edit" => "devise/passwords#edit"
put "account/password" => "devise/passwords#update"
...
end
您可能还需要自定义 View 以指向您声明的新路径。请参阅 Devise wiki 以了解如何自定义 View 。
关于ruby-on-rails - "devise_for"、 "devise_scope"出现问题!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5503485/
我正在尝试在设计中自定义我的路线。我尝试使用 devise_scope :user,但它不起作用。所以我改为 devise_for,并跳过了自定义路由(注册、确认、密码、 session )并且它起作
我是一名优秀的程序员,十分优秀!