开发者

Rails callback - creating :on_login callback for a user model?

Rails provides a great feature that is model callback开发者_运维知识库. These callbacks matches steps of an Active record object life cycle : after_save, before_validation, etc...

Therefore I'm wondering if we could has specific callbacks. For instance, :after_login, :before_login, :after_logout, ... for an user model would be great. How would one do that ?

There's the obvious way : inside your controller. Is there another one ?


It's really very specific to your system, like how your user is logged or not.

You need to do yourself this callback. You can use the ActiveSupport::Callback to do that. You can made some feature request on your Authentication plugin.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜