I should add that this requires that you comment out the

   config.frameworks -= [ :action_mailer ]

if you specify the rails gem in your Gemfile (meaning you are using the Rails gem, not the vendor'ed rails that ships with the Radiant gem).

For me, I have to specify the rails gem because I'm deploying to Heroku.

W



On 6/2/11 5:04 PM, Wes Gamble wrote:
All,

This is really bundler stuff, but if you want to use bundler to manage gem dependencies (a la Rails 3) instead of using config.gem commands in environment.rb, here's how you do it:

1) Generate your Gemfile in Rails.root as normal and use bundle install and bundle update to manage your gems 2) Add a file named "preinitializer.rb" to Rails.root/config with the following content:

begin
  require "rubygems"
  require "bundler"
rescue LoadError
raise "Could not load the bundler gem. Install it with `gem install bundler`."
end

if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
  raise RuntimeError, "Your bundler version is too old for Rails 2.3." +
   "Run `gem install bundler` to upgrade."
end

begin
  # Set up load paths for all bundled gems
  ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
  Bundler.setup
rescue Bundler::GemNotFound
  raise RuntimeError, "Bundler couldn't find some gems." +
    "Did you run `bundle install`?"
end

This will allow you to remove all of the config.gem entries from environment.rb and make it slightly easier to upgrade to Rails 3 someday.

Thanks,
Wes

Reply via email to