NoMethodError: undefined method `url_for'

Hi every one,

I wrote a Utility class for my application, and i want to use
“url_for”, I included the url_helper but i get this error

NoMethodError: undefined method `url_for’ for UtilityBatch:Class

  • i tried require ‘action_view/helpers/url_helper.rb’
    include ActionView::Helpers::UrlHelper … with no result

… i was able to construct the urls as strings but i was wondering
what do i need to do to use url_for in my class.

All input is appreciated.

Thank you.

jimache wrote:

I wrote a Utility class for my application, and i want to use
“url_for”, I included the url_helper but i get this error

NoMethodError: undefined method `url_for’ for UtilityBatch:Class

  • i tried require ‘action_view/helpers/url_helper.rb’
    include ActionView::Helpers::UrlHelper … with no result

… i was able to construct the urls as strings but i was wondering
what do i need to do to use url_for in my class.

Try using “extend” instead of “include” so as to make the url helpers
class methods.


We develop, watch us RoR, in numbers too big to ignore.

Did you find the solution? Am facing the same issue.

Thanks,
Pratik