Can we call a Controller's method from a view (as we call from helper ideally)?

Solution 1:

Here is the answer:

class MyController < ApplicationController
  def my_method
    # Lots of stuff
  end
  helper_method :my_method
end

Then, in your view, you can reference it in ERB exactly how you expect with <% or <%=:

<% my_method %>

Solution 2:

You possibly want to declare your method as a "helper_method", or alternatively move it to a helper.

What do helper and helper_method do?