新手问题 定义好方法之后报了 NoMethodError

ThanksSirAlec · May 15, 2018 · Last by adamshen replied at May 15, 2018 · 943 hits
module Gitlab
  module Client
    class << self
      def foo
        'it is a method'
      end
    end
  end
end

我在 rails c 里面用 Gitlab::Client.foo 出现了 NoMethodError: undefined method 'foo' for Gitlab::Client:Class

这是为什么

代码写的有问题吧?在 irb 下没问题

是不是之前没有定义的时候进的 console, 然后改了之后没有 reload?

You need to Sign in before reply, if you don't have an account, please Sign up first.