问题覆盖 Devise::RegistrationsController

发布于 2024-11-19 11:09:45 字数 1273 浏览 1 评论 0原文

我读过类似的文章,例如 覆盖设计注册控制器,但我的应用程序中的 Devise 没有正确覆盖。

我在 Mac (OSX 10.6.8) 上使用 Devise 1.4.2 和 Rails 3.0.9。

# app/controllers/registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
  def new
    debugger
  end

  def create
    debugger
  end
end

# config/routes.rb
devise_for :users, :controllers => {:registrations => "registrations"}

然后我使用 --debugger 选项启动本地服务器(安装了 ruby​​-debug19),当访问 /users/sign_up 时,调试器不会触发。

rails server --debugger

Started GET "/users/sign_up" for 127.0.0.1 at 2011-07-11 21:21:46 +0900
Processing by Devise::RegistrationsController#new as HTML
Rendered devise/shared/_links.erb (3.8ms)
Rendered devise/registrations/new.html.erb within layouts/application (20.4ms)

更新:我用“rake paths”检查了我的路由,但是sign_up的路由仍然如下。

user_registration POST /users(.:format) {
    :action=>"create", :controller=>"devise/registrations"}
new_user_registration GET /users/sign_up(.:format) {
    :action=>"new", :controller=>"devise/registrations"}

我希望 :controller 在 POST 时指向“registrations”(没有“devise/”)。 我缺少什么?

I've read similar articles like Override devise registrations controller , but Devise in my app doesn't override correctly.

I am using Devise 1.4.2 and Rails 3.0.9 on my Mac (OSX 10.6.8).

# app/controllers/registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
  def new
    debugger
  end

  def create
    debugger
  end
end

# config/routes.rb
devise_for :users, :controllers => {:registrations => "registrations"}

Then I started my local server with --debugger option (ruby-debug19 is installed) and when access to /users/sign_up, debugger doesn't trigger.

rails server --debugger

Started GET "/users/sign_up" for 127.0.0.1 at 2011-07-11 21:21:46 +0900
Processing by Devise::RegistrationsController#new as HTML
Rendered devise/shared/_links.erb (3.8ms)
Rendered devise/registrations/new.html.erb within layouts/application (20.4ms)

Updated: I checked my routings with "rake routes", but the routing for sign_up still remains as below.

user_registration POST /users(.:format) {
    :action=>"create", :controller=>"devise/registrations"}
new_user_registration GET /users/sign_up(.:format) {
    :action=>"new", :controller=>"devise/registrations"}

I want :controller to point "registrations" (without "devise/") when POST.
What am I missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妖妓 2024-11-26 11:09:45

在你的routes.rb文件中,

你可以通过以下方式修改你的设计路线:

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

In your routes.rb file,

You can amend your devise routes in the following way:

devise_for :users, :controllers => { :registrations => 'registrations' }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文