I have a rails project that uses mongo db, and I wrote a mounted engine called "report_service".
I used it like this in the main rails project:
gem 'report_service', :git => ' git@xx.com :report_service.git', :branch => :master, :require => false
I do not want this pearl to load when the rails project is initialized, so I added the parameter :require => false .
But in my rails console after executing require 'report_service' I can not find the models in this stone.
[1] pry(main)> ReportService => ReportService [2] pry(main)> ReportService::Engine NameError: uninitialized constant ReportService::Engine from (pry):2:in `<main>' [3] pry(main)> require 'report_service' => true [4] pry(main)> ReportService::Engine => ReportService::Engine [5] pry(main)> ReportService::RsExam NameError: uninitialized constant ReportService::RsExam from (pry):5:in `<main>'
Here is my directory and gem.service code:
report_service / Library / report_service.rb
require "active_record/railtie" require "report_service/engine" module ReportService end
report_service / Library / report_service / engine.rb
module ReportService class Engine < ::Rails::Engine isolate_namespace ReportService end end
report_service / application / models / report_service / rs_exam.rb
module ReportService class RsExam < ActiveRecord::Base end end
source share