Search code examples
ruby-on-railshelperpartial

rails use helper in partial


I have a shared partial in

-shared
└──-foo
   └──-bar
      └──baz.html.erb

And in it I'm trying to access a helper method in

-helpers
└──foo_helper.rb

But I am getting un undefined method error.

How can I include that helper method in my partial in an elegant way?


Solution

  • Put

    helper :foo
    

    in your application controller. This should make the helpers in foo_helper available across all actions.