Search code examples
rubysinatrabundler

Sinatra + Bundler?


I'm wondering how one can use Bundler with Sinatra. The idea is to use the gems that Bundler downloads inside the .gems folder.


Solution

  • I believe the best way is described here on EngineYard blog:

    # This makes sure the bundled gems are in our $LOAD_PATH
    require File.expand_path(File.join(File.dirname(__FILE__), 'vendor', 'gems', 'environment'))
    
    # This actually requires the bundled gems
    Bundler.require_env
    
    class MyApp < Sinatra::Base
      # stuff
    end