diff options
author | Ben Sandofsky <sandofsky@gmail.com> | 2008-08-01 17:01:10 -0700 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-08-04 14:53:21 +0200 |
commit | 61842d97c5269af8a36a33115f50543a155f1608 (patch) | |
tree | 6b08b69619f1a0aa9a727a5dfaeaff1e1dead69f /railties/lib | |
parent | 82343859d568799a4151facbde1f8c711ecb7a3f (diff) | |
download | rails-61842d97c5269af8a36a33115f50543a155f1608.tar.gz rails-61842d97c5269af8a36a33115f50543a155f1608.tar.bz2 rails-61842d97c5269af8a36a33115f50543a155f1608.zip |
Make requiring gems optional.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#743 state:resolved]
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/initializer.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/gem_dependency.rb | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index a2d08e2938..e876481cf1 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -688,13 +688,17 @@ Run `rake gems:install` to install the missing gems. # You can add gems with the #gem method. attr_accessor :gems - # Adds a single Gem dependency to the rails application. + # Adds a single Gem dependency to the rails application. By default, it will require + # the library with the same name as the gem. Use :lib to specify a different name. # # # gem 'aws-s3', '>= 0.4.0' # # require 'aws/s3' # config.gem 'aws-s3', :lib => 'aws/s3', :version => '>= 0.4.0', \ # :source => "http://code.whytheluckystiff.net" # + # To require a library be installed, but not attempt to load it, pass :lib => false + # + # config.gem 'qrp', :version => '0.4.1', :lib => false def gem(name, options = {}) @gems << Rails::GemDependency.new(name, options) end diff --git a/railties/lib/rails/gem_dependency.rb b/railties/lib/rails/gem_dependency.rb index f8d97840c1..471e03fa5f 100644 --- a/railties/lib/rails/gem_dependency.rb +++ b/railties/lib/rails/gem_dependency.rb @@ -58,7 +58,7 @@ module Rails def load return if @loaded || @load_paths_added == false - require(@lib || @name) + require(@lib || @name) unless @lib == false @loaded = true rescue LoadError puts $!.to_s |