Rails technoweenie / Restful-authentication magi-code:找不到“User#register!”

发布于 2024-07-16 09:00:46 字数 248 浏览 5 评论 0原文

我最近安装了 technoweenie/restful-authentication 插件(按承诺工作),但是在浏览 users_controller#created 时,我发现了对 user 上方法调用的引用model

 @user.register!

有谁知道该方法是在哪里定义的吗? 我几乎搜索了所有生成的代码,但仍然没有看到注册方法。

I recently installed the technoweenie / restful-authentication plugin (which works as promised), but while going through users_controller#created, I found a reference to a method call on the user model

 @user.register!

Does anyone know where the method is defined? I've pretty much search all of the generated code, and still don't see a register method.

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

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

发布评论

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

评论(2

江心雾 2024-07-23 09:00:46

它在restful-authentication/lib/authorization/stateful_roles.rb中定义。

    event :register do
      transitions :from => :passive, :to => :pending, :guard => Proc.new {|u| !(u.crypted_password.blank? && u.password.blank?) }
    end

实际的方法register!是由acts_as_state_machine插件从该事件动态创建的,该插件也应该在您的项目中。 此方法已插入到您的控制器中,因为在生成控制器时您指定了 --stateful 或“--aasm”。

关于acts_as_state_machine 如果您想了解更多信息,请点击此处

It's defined in restful-authentication/lib/authorization/stateful_roles.rb

    event :register do
      transitions :from => :passive, :to => :pending, :guard => Proc.new {|u| !(u.crypted_password.blank? && u.password.blank?) }
    end

The actual method register! is created dynamically from this event by the acts_as_state_machine plugin that should be in your project as well. This method was inserted into your controller because when you generated your controller you specified either --stateful or '--aasm'.

There is a very good write up on acts_as_state_machine here if you would like to learn more.

蛮可爱 2024-07-23 09:00:46

运行 Restful auth 生成器

Run the restful auth generators

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