开发者

helper:all doesn't seem to be working

In my application_controller.rb I have:

class ApplicationController < ActionController::Base

   helper :all


   def test1?
      true
   end

   def test2?
      false
   end


end

I can an error if I try and put <%= test1? %> or test2 开发者_运维百科in my views.

It works if I add the methods like:

helper_method  :test1?, :test2?

But its a pain to do this for each method, is there a better way to globally add them?


You have the definition of helper :all wrong.

helper :all invokes require on all of your helper classes within the app/helpers directory.

In order to have the methods you provided be accessible in all views, you can move them to the application_helper.rb file.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜