user414381
user414381

Reputation:

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?

Upvotes: 2

Views: 921

Answers (1)

Chirantan
Chirantan

Reputation: 15634

You might want to try

ActionView::Helper.send :include, MyHelper

Upvotes: 1

Related Questions