Rails technoweenie / Restful-authentication magi-code:找不到“User#register!”
我最近安装了 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它在restful-authentication/lib/authorization/stateful_roles.rb中定义。
实际的方法
register!
是由acts_as_state_machine插件从该事件动态创建的,该插件也应该在您的项目中。 此方法已插入到您的控制器中,因为在生成控制器时您指定了--stateful
或“--aasm”。关于acts_as_state_machine 如果您想了解更多信息,请点击此处。
It's defined in restful-authentication/lib/authorization/stateful_roles.rb
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.
运行 Restful auth 生成器
Run the restful auth generators