User Assistant Volume

I defined my helper function in Helper:

module CarsHelper

  def my_helper
    ...
  end

end

But I can not use it (my_helper) in my model CarsControlleror in Car, so that the user assistant can only be used in the view?

+5
source share
2 answers

Assistants usually relate to submissions. But you can include them in your controllers. Just add

helper :cars

to your controller. ( docs )

Models are not available for assistants. Use class or instance methods instead.

+5
source

A new way to use view helpers in controllers is to use: helpers.[helpername]

.

0

All Articles