[英]When writing a gem, how do you get access to helpers?
For a gem, i'm writing, I want to be able to access current_user (most auth systems have this helper) 对于一个宝石,我正在写,我希望能够访问current_user(大多数身份验证系统都有此帮助器)
What are some ways of doing that? 有哪些方法可以做到这一点?
the thing that the controller includes to get current_user is this AuthenticatedSystem
not sure how the helpers get access to it's contents 控制器要获取current_user所包括的是此
AuthenticatedSystem
不确定助手如何访问其内容
*I'm using RestfulAuth *我正在使用RestfulAuth
If your gem has modules that get included on controllers, you can test if the method is available: 如果您的gem具有包含在控制器中的模块,则可以测试该方法是否可用:
self.respond_to?( :current_user )
And if it is just call it. 如果只是调用它。 If your gem really needs it it would even raise an error if the method is not available.
如果您的宝石确实需要它,如果该方法不可用,它甚至会引发错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.