Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: using helper methods from config

How would I go about using helper methods from a config file?

This may be unorthodox but it makes sense in the context that I need it. The helper method I need is used to properly format URLs in one of my views. The config file is the initializer for the sitemap_generator Gem, where I need the helper method to format some of the URLs.

I tried require, which does indeed include the module, but get undefined method for module when I call it.

like image 975
StrangeElement Avatar asked Jul 08 '26 16:07

StrangeElement


1 Answers

This is how you include your helper in the SitemapGenerator config :

SitemapGenerator::Interpreter.send :include, ApplicationHelper

like image 115
Jim Avatar answered Jul 11 '26 17:07

Jim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!