If you intend to use your gem with Rails 3, you can provide Railtie . Then you can automatically download it if you use Rails.
Assuming the name of your gem is tbbc , put this in lib/tbbc/railtie.rb :
module TBBC class Railtie < Rails::Railtie initializer "tbbc.insert_middleware" do |app| app.config.middleware.use "TBBC::Editor::Middleware" end end end
In lib/tbbc.rb :
require "tbbc/railtie" if defined? Rails
You cannot automatically add middleware to common Rack applications. For applications other than Rails, this will be what the user should do.
source share