在lib下编写的自己的类需要用到model内相关方法

我们在lib下编写的自己的类需要用到model内相关方法时,需要如下设置:

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

posted @ 2017-09-13 11:51  -梦里不知身是客  阅读(191)  评论(0编辑  收藏  举报