开发者

Rails 2.3.5 engine (plugin) how to specify gem requirements

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

Basically, I need to be able to call "config.gem" after Initializer.run has been called by environment.rb, since the plugin has not been loaded when the config block is in开发者_运维百科 scope.

Not using bundler for this application.


I think that you can run the Rails Initializer stuff inside your init.rb eg just stuff like:

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

If putting it in init.rb doesn't call it, one of our engines has a bootfile that simply contains a class with a method that contains the same Initialiser stuff as above. eg:

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

The bootfile is required in the environment.rb and the class method called eg

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜