NoMethodError when trying to invoke helper method from Rails controller

前端 未结 14 1191
滥情空心
滥情空心 2020-11-30 20:05

I\'m getting a NoMethodError when trying to access a method defined in one of my helper modules from one of my controller classes. My Rails application uses the

14条回答
  •  悲哀的现实
    2020-11-30 20:53

    For Rails 3, use the view_context method in your controller:

    def foo
      view_context.helper_method
      ...
    

    Here's an example: http://www.christopherirish.com/2011/10/13/no-view_context-in-rails-3-1-changes/

提交回复
热议问题