Rails通过引擎制作宝石

时间:2016-07-23 15:26:04

标签: ruby-on-rails rubygems rails-engines

我想创建一个包含视图助手的gem。我看这个tutorial, 但我遇到了一些问题。

如果您需要更多信息,请github

帮助者只会打印< >

应用/助手/ google_code.rb

VectorXd(b->rows())

LIB / google_prettify_rails.rb     要求&#34; google_prettify_rails / version&#34;

Hello world!

然后,我创建了另一个项目并安装了它,并在视图中输入module GoogleCode def self.put_code content_tag(:p, "Hello world!") end end 。但是,它抛出了这个错误

module GooglePrettifyRails
    class Engine < ::Rails::Engine
    end
end

1 个答案:

答案 0 :(得分:2)

帮助程序的名称和帮助程序所在文件的名称不匹配。只需将app/helpers/google_prettify_rails_helper.rb的第一行更改为GooglePrettifyRailsHelper