开发者

Including Custom Helper Method in Ruby Gem

I've been attempting to add a helper method to my ruby gem for use with Rails 3.

Here is an example of what I am attempting to achieve:

module MyHelper

def my_method
    render :text => "Hello World!"
end

end

I've tried prepending MyHelper.rb with:

ActionView::Base.send :include,开发者_开发技巧 MyHelper

And I've also tried adding the above line to an init.rb file without success.

Here is the code from the view... Maybe I am implementing it wrong?

<%= yield my_method %>

Any suggestions?


You might want to try

ActionView::Helper.send :include, MyHelper
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜