How do you gain access to the helper methods inside the controller with Rails

297 Views Asked by At

I want to use a method i have in my helper inside my controller. I don't know how to use the view_context which i've heard could do the trick

2

There are 2 best solutions below

0
mark On BEST ANSWER

As apneadiving said, make it a controller method and make that a helper method.

application_controller.rb

  helper_method :do_stuff

  def do_stuff
    #this method is available in all controllers and views
0
jimworm On

I vote for @apneadiving's idea. But here goes:

class SomeController < ApplicationController
  include SomeHelper
end