开发者

How do you gain access to the helper methods inside the controller with Rails

开发者 https://www.devze.com 2023-03-18 07:27 出处:网络
开发者_高级运维I want to use a method i have in my helper inside my controller. I don\'t know how to use the view_context which i\'ve heard could do the trickAs apneadiving said, make it a controller
开发者_高级运维

I want to use a method i have in my helper inside my controller. I don't know how to use the view_context which i've heard could do the trick


As apneadiving said, make it a controller method and make that a helper method.

application_controller.rb

  helper_method :do_stuff

  def do_stuff
    #this method is available in all controllers and views


I vote for @apneadiving's idea. But here goes:

class SomeController < ApplicationController
  include SomeHelper
end
0

精彩评论

暂无评论...
验证码 换一张
取 消