I created a gem Helloword
with the command:
我用命令创建了一个gem Helloword:
bundle gem helloword
I built the gem with the command:
我用命令构建了gem:
gem build helloword.gemspec
I edited the Gemfile
of my Rails app:
我编辑了我的Rails应用程序的Gemfile:
gem 'helloword', '0.1.0', path: '/Users/iloveyou/helloword'
and I installed the gem:
我安装了gem:
bundle install
I am using the gem in my page like:
我在我的页面中使用gem如:
<h1><%= hello_word_tag %></h1>
I get the result:
我得到了结果:
Why did adding my gem to the website not work?
为什么在网站上添加我的宝石不起作用?
2 个解决方案
#1
1
Because you haven't called the module Helloword
.
因为你还没有调用Helloword模块。
#2
0
i Fixed: Change:
我修正:改变:
def hello_word_tag
"Hello Word!!!"
end
to:
至:
def self.hello_word_tag
"Hello Word!!!"
end
and call:
并致电:
<h1><%= Helloword.hello_word_tag %></h1>
#1
1
Because you haven't called the module Helloword
.
因为你还没有调用Helloword模块。
#2
0
i Fixed: Change:
我修正:改变:
def hello_word_tag
"Hello Word!!!"
end
to:
至:
def self.hello_word_tag
"Hello Word!!!"
end
and call:
并致电:
<h1><%= Helloword.hello_word_tag %></h1>