diff options
-rw-r--r-- | Gemfile | 1 | ||||
-rw-r--r-- | actionpack/actionpack.gemspec | 1 | ||||
-rw-r--r-- | railties/lib/rails/application.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/Gemfile | 4 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 5 |
5 files changed, 16 insertions, 1 deletions
@@ -6,6 +6,7 @@ gem 'arel', github: 'rails/arel', branch: 'master' gem 'mocha', '>= 0.11.2', :require => false gem 'rack-test', github: 'brynary/rack-test' +gem 'rack-cache', "~> 1.2" gem 'bcrypt-ruby', '~> 3.0.0' gem 'jquery-rails' diff --git a/actionpack/actionpack.gemspec b/actionpack/actionpack.gemspec index fd09d3b55b..7d292ac17c 100644 --- a/actionpack/actionpack.gemspec +++ b/actionpack/actionpack.gemspec @@ -18,7 +18,6 @@ Gem::Specification.new do |s| s.requirements << 'none' s.add_dependency('activesupport', version) - s.add_dependency('rack-cache', '~> 1.2') s.add_dependency('builder', '~> 3.1.0') s.add_dependency('rack', '~> 1.4.1') s.add_dependency('rack-test', '~> 0.6.1') diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 050190cba6..0b9ed025db 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -282,6 +282,12 @@ module Rails ActionDispatch::MiddlewareStack.new.tap do |middleware| app = self if rack_cache = config.action_controller.perform_caching && config.action_dispatch.rack_cache + begin + require 'rack/cache' + rescue LoadError => error + error.message << ' Be sure to add rack-cache to your Gemfile' + raise + end require "action_dispatch/http/rack_cache" middleware.use ::Rack::Cache, rack_cache end diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index 55a6b3f4f2..69027f2903 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -9,6 +9,10 @@ source 'https://rubygems.org' <%= assets_gemfile_entry %> <%= javascript_gemfile_entry %> +# Puts a simple HTTP cache in front of your app. +# For large-scale production use, consider using a caching reverse proxy like nginx, varnish, or squid. +gem 'rack-cache', '~> 1.2' + # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 856a0e163b..7a646626c6 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -300,6 +300,11 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_file "Gemfile", /# gem 'debugger'/ end + def test_inclusion_of_rack_cache + run_generator + assert_file "Gemfile", /gem 'rack-cache'/ + end + def test_template_from_dir_pwd FileUtils.cd(Rails.root) assert_match(/It works from file!/, run_generator([destination_root, "-m", "lib/template.rb"])) |