Reputation: 15107
I recently externalized my rails models outside of my rails-app into a gem (models_gem).
When my rails project imports the models_gem, i have to do a: require 'model' , in order to use the model. How can I automatically import all the models that are in my models_gem ??
Upvotes: 1
Views: 1970
Reputation: 3761
you can do it in Gemfile eg:
gem 'models_gem', require: 'models_gem'
or fix your gem and in lib/models_gem.rb
ActiveRecord::Base.send(:include, ModelsGem)
Thats depends how your gem is made.
Upvotes: 2
Reputation: 51697
When you require a gem, it requires lib/gem_name.rb. If you require all the models in that file, in theory they should be loaded in your application.
Upvotes: 1