开发者

Do helper classes get mixed into the controller?

开发者 https://www.devze.com 2023-03-21 09:57 出处:网络
If I have a homecontroller, will the home_helper.rb get mixed into the controller class? I\'m assuming so as it gets 开发者_开发百科access to the request object somehow.No, helpers do not get mixed i

If I have a homecontroller, will the home_helper.rb get mixed into the controller class?

I'm assuming so as it gets 开发者_开发百科access to the request object somehow.


No, helpers do not get mixed into controllers. You can hack rails but your best bet is to just include the method in application_helper.rb

This seems to be the best hack:

http://snippets.aktagon.com/snippets/47-Using-Rails-helpers-from-controllers-or-anywhere-you-want

0

精彩评论

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