I'm creating a helper to be used by Formtastic but I get the undefined local variable or method
error. I don't know where to put it so it can work.
I already tried in the application_helper.rb and in app/helpers/active_admin/view_helpers.rb
A Helper method is used to perform a particular repetitive task common across multiple classes. This keeps us from repeating the same piece of code in different classes again and again. And then in the view code, you call the helper method and pass it to the user as an argument.
In Rails 5, by using the new instance level helpers method in the controller, we can access helper methods in controllers.
You can define them in app/helpers/ as you tried but you need to include them trough the active admin's initializer like this:
# in config/initializers/active_admin.rb ActiveAdmin.setup do |config| .... end module ActiveAdmin::ViewHelpers include ApplicationHelper end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With