我知道这里已经多次询问过这个问题了(我也通过wiki阅读)。 但是我仍然对如何正确保持路线名称一致感到困惑。
目前我的设计路线在下面,使用自定义网址(例如/user/signup )。
我的模型叫做User
路线:
devise_for :users, :controllers => { :registrations => "registrations" }, :path_names => { :sign_up => 'signup' } devise_for :users, :path => "user", :except => "create", :path_names => { :sign_in => 'login', :sign_out => 'logout', :password => 'forgot-password', :confirmation => 'verification', :unlock => 'unblock', :sign_up => 'signup' }我所要做的就是挂钩创建操作,以便检查我创建的蜜罐字段是否已填写(以防止垃圾邮件)。 这就是我想要做的。
我想保持我的网址相同/user/signup 。 我需要做额外的步骤吗?
这是我迄今为止在...
/app/controllers/registrations_controller.rb
class Users::RegistrationsController < Devise::RegistrationsController def new super end def create super end end我正在获取uninitialized constant Users
I realize this has been asked many times on here (I also read through the wiki). But I am still confused at how to properly keep my route names the same.
Currently my devise routes are below, using custom url's (for example /user/signup).
My model is called User
Routes:
devise_for :users, :controllers => { :registrations => "registrations" }, :path_names => { :sign_up => 'signup' } devise_for :users, :path => "user", :except => "create", :path_names => { :sign_in => 'login', :sign_out => 'logout', :password => 'forgot-password', :confirmation => 'verification', :unlock => 'unblock', :sign_up => 'signup' }All I am trying to do is hook into the create action so I can check if a honeypot field I have created is filled out (to prevent spam). That's really all I want to do.
I want to keep my url the same though /user/signup. Is there an extra step I need to do?
This is what I have so far in...
/app/controllers/registrations_controller.rb
class Users::RegistrationsController < Devise::RegistrationsController def new super end def create super end endI am getting uninitialized constant Users
最满意答案
很简单,我需要将控制器放在'用户'文件夹中,并且解决了所有问题。 (此外,路由控制器需要:registrations => "users/registrations"
Quite simply I needed to put the controller in a 'users' folder, and that fixed everything. (Also, the route controller needs to be :registrations => "users/registrations"
更多推荐
发布评论