Reputation: 4634
I want to make a gem which contains a view helper. I watch this tutorial, but I encounter some problems.
Here is github if you need more information.
The helper would only print Hello world!
.
app/helpers/google_code.rb
module GoogleCode
def self.put_code
content_tag(:p, "Hello world!")
end
end
lib/google_prettify_rails.rb require "google_prettify_rails/version"
module GooglePrettifyRails
class Engine < ::Rails::Engine
end
end
Then, I created another project and installed it, and I type <%= put_code %>
in view. However, it threw this error
Couldn't find GooglePrettifyRailsHelper, expected it to be defined in helpers/google_prettify_rails_helper.rb
Upvotes: 0
Views: 31
Reputation: 3048
The name of your helper and the name of the file the helper is in do not match. Just change first line of app/helpers/google_prettify_rails_helper.rb
to GooglePrettifyRailsHelper
.
Upvotes: 2