Monday, April 13, 2015

How to Load Dependencies in a Rails Engine

In a Rails project, generally all you have to do is add a gem to your Gemfile and the dependencies will automagically get taken care of. Unfortunately, for Rails Engines this is not the case. You will have to take the additional step of requiring the gem's library file.

# engine.gemspec s.add_dependency 'jquery-rails' s.add_dependency 'your-foo-gem' # lib/your_engine/engine.rb
require 'jquery-rails'
require 'your-foo-gem'


This is related to the problem of needing to require modules from gems to get them to load properly.