undefined method 'link_to' undefined method 'link_to' ruby-on-rails ruby-on-rails

undefined method 'link_to'


Try this:

ActionController::Base.helpers.link_to


This is because, ActionView urlhelpers are only available to the Views, not in your lib directory.

the link_to method is found in the ActionView::Helpers::UrlHelper module, plus you wou

so try this.

 class Facet   include ActionView::Helpers::UrlHelper...end


Simply including the helper doesn't get you much further. The helpers assume that they are in the context of a request, so that they can read out the domain name and so on.

Do it the other way around; include your modules in the application helper, or something like that.

# lib/my_custom_helper.rbmodule MyCustomHelper  def do_stuff    # use link_to and so on  endend# app/helpers/application_helper.rbmodule ApplicationHelper  include MyCustomHelperend