Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
rails应用程序中的Ruby-gem可见性_Ruby - Fatal编程技术网

rails应用程序中的Ruby-gem可见性

rails应用程序中的Ruby-gem可见性,ruby,Ruby,我创建了名为gotqn_first_gem的简单gem,在我的gotqn_first_gem.rb文件中,我有以下代码: require "gotqn_first_gem/version" module GotqnFirstGem class Test def initialize(parameters = {}) @url = 'Hello World' end # def to_s "<p>#{@url}<p

我创建了名为
gotqn_first_gem
的简单gem,在我的
gotqn_first_gem.rb
文件中,我有以下代码:

require "gotqn_first_gem/version"

module GotqnFirstGem
  class Test

    def initialize(parameters = {})
      @url = 'Hello World'
    end

    #
    def to_s
      "<p>#{@url}<p/>"
    end

  end
end

有人能告诉我们如何成功地要求和使用gem代码,以及为什么gem代码在整个应用程序中不可见吗?

Test
不存在,
GotqnFirstGem::Test
存在。所以你需要做:

GotqnFirstGem::Test.new
相反

GotqnFirstGem::Test.new