新手问题 lib 下如何使用 rails 里面相关方法

dccmmtop · 2017年09月12日 · 最后由 hww 回复于 2017年09月13日 · 1229 次阅读
module CoinDealApi
  class Utils
     def get_object(platform) 
          Rails.logger.info "not found"
      end
  end
end

config/application.rb

require_relative 'boot'

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module DomesticTrade
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.
    config.autoload_paths += [
      Rails.root.join('lib')
    ]
    config.eager_load_paths += [
      Rails.root.join('lib/coin_deal_api')
    ]
  end
end

报的错误:` get_object': uninitialized constant #Class:CoinDealApi::Utils::Rails (NameError),

这里应该怎么弄??

我这里都可以,不会报错,不知道你是怎么使用的。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号