Rails 2.3.5 engine (plugin) how to specify jewel requirements

When creating the rails engine in 2.3.5 as a plugin, how can I install the gem dependencies inside the plugin without having to import them into the environment.rb host applications?

Basically, I need to be able to call "config.gem" after Initializer.run was called by environment.rb, because the plugin was not loaded when the configuration block is in scope.

Do not use the package for this application.

+3
source share
1 answer

I think you can run the Rails Initializer stuff inside your init.rb, for example, just things like:

Rails::Initializer.run do |config|
  config.gem 'fastercsv', :version => '1.4.0'    
  config.gem 'liquid', :version => '2.0.0'
end

init.rb , , , Initialiser, . :

class MyBootClass
  def self.boot_up  
    Rails::Initializer.run do |config|
      config.gem 'fastercsv', :version => '1.4.0'    
      config.gem 'liquid', :version => '2.0.0'
    end
  end
end

environment.rb , , ,

require "#{File.dirname(__FILE__)}/../vendor/plugins/.../bootfile.rb"
MyBootClass.boot_up
0

Source: https://habr.com/ru/post/1755369/


All Articles