From a47d4096b90f00ff40b2d1c1376d110aababe239 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 25 Feb 2012 21:25:15 -0700 Subject: [PATCH] Upgrade to rails 3.1 --- config/application.rb | 18 ++++++++----- config/environment.rb | 4 --- config/environments/development.rb | 9 +++++-- config/environments/production.rb | 35 +++++++++++++++++--------- config/environments/test.rb | 6 ++++- config/initializers/secret_token.rb | 2 +- config/initializers/session_store.rb | 2 +- config/initializers/wrap_parameters.rb | 14 +++++++++++ config/locales/en.yml | 5 +--- 9 files changed, 64 insertions(+), 31 deletions(-) create mode 100644 config/initializers/wrap_parameters.rb diff --git a/config/application.rb b/config/application.rb index a567b35..5ec8fce 100644 --- a/config/application.rb +++ b/config/application.rb @@ -2,9 +2,12 @@ require 'rails/all' -# If you have a Gemfile, require the gems listed there, including any gems -# you've limited to :test, :development, or :production. -Bundler.require(:default, Rails.env) if defined?(Bundler) +if defined?(Bundler) + # If you precompile assets before deploying to production, use this line + Bundler.require(*Rails.groups(:assets => %w(development test))) + # If you want your assets lazily compiled in production, use this line + # Bundler.require(:default, :assets, Rails.env) +end module LandInfo class Application < Rails::Application @@ -30,13 +33,16 @@ class Application < Rails::Application # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de - # JavaScript files you want as :defaults (application.js is always included). - # config.action_view.javascript_expansions[:defaults] = %w(jquery rails) - # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] + + # Enable the asset pipeline + config.assets.enabled = true + + # Version of your assets, change this if you want to expire all your assets + config.assets.version = '1.0' end end diff --git a/config/environment.rb b/config/environment.rb index 173dcb4..dbaa877 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,9 +1,5 @@ # Load the rails application require File.expand_path('../application', __FILE__) -unless $CLASSPATH.nil? - $CLASSPATH << "file:///#{Rails.root}/lib/java/mysql-connector-java-5.1.15-bin.jar" -end - # Initialize the rails application LandInfo::Application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 637f446..268b083 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -3,7 +3,7 @@ # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development - # since you don't have to restart the webserver when you make code changes. + # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Log error messages when you accidentally call methods on nil. @@ -21,5 +21,10 @@ # Only use best-standards-support built into browsers config.action_dispatch.best_standards_support = :builtin -end + # Do not compress assets + config.assets.compress = false + + # Expands the lines which load the assets + config.assets.debug = true +end diff --git a/config/environments/production.rb b/config/environments/production.rb index a45b4fd..a5317bf 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,7 +1,6 @@ LandInfo::Application.configure do # Settings specified here will take precedence over those in config/application.rb - # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true @@ -9,14 +8,27 @@ config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Specifies the header that your server uses for sending files - config.action_dispatch.x_sendfile_header = "X-Sendfile" + # Disable Rails's static asset server (Apache or nginx will already do this) + config.serve_static_assets = false + + # Compress JavaScripts and CSS + config.assets.compress = true + + # Don't fallback to assets pipeline if a precompiled asset is missed + config.assets.compile = false + + # Generate digests for assets URLs + config.assets.digest = true - # For nginx: - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' + # Defaults to Rails.root.join("public/assets") + # config.assets.manifest = YOUR_PATH - # If you have no front-end server that supports something like X-Sendfile, - # just comment this out and Rails will serve the files + # Specifies the header that your server uses for sending files + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true # See everything in the log (default is :info) # config.log_level = :debug @@ -27,13 +39,12 @@ # Use a different cache store in production # config.cache_store = :mem_cache_store - # Disable Rails's static asset server - # In production, Apache or nginx will already do this - config.serve_static_assets = false - - # Enable serving of images, stylesheets, and javascripts from an asset server + # Enable serving of images, stylesheets, and JavaScripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" + # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) + # config.assets.precompile += %w( search.js ) + # Disable delivery errors, bad email addresses will be ignored # config.action_mailer.raise_delivery_errors = false diff --git a/config/environments/test.rb b/config/environments/test.rb index 562d3fe..51ebf5c 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -7,7 +7,11 @@ # and recreated between test runs. Don't rely on the data there! config.cache_classes = true - # Log error messages when you accidentally call methods on nil. + # Configure static asset server for tests with Cache-Control for performance + config.serve_static_assets = true + config.static_cache_control = "public, max-age=3600" + + # Log error messages when you accidentally call methods on nil config.whiny_nils = true # Show full error reports and disable caching diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index d766913..fd22c84 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -4,4 +4,4 @@ # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. -LandInfo::Application.config.secret_token = 'f7d7793d4674a0bc2ebce2b380c459cd0eeda08e6033af0eb16247d3503d6261f99dfe3290c12504b58cbd1c4678ae1d7a546147a9100604a90ebd9027baa5fd' +LandInfo::Application.config.secret_token = '32e2452da9683cb2acfc2ce223fa5fc93c7f439d43df4a3513a0780af967e2a1a2e16c1e3d4e94bae16601b39b62db638cba079e4a521cb7e64ba61d7b30912e' diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 6dc5d76..e55e919 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,6 +1,6 @@ # Be sure to restart your server when you modify this file. -LandInfo::Application.config.session_store :cookie_store, :key => '_land_info_session' +LandInfo::Application.config.session_store :cookie_store, key: '_land_info_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..999df20 --- /dev/null +++ b/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# Disable root element in JSON by default. +ActiveSupport.on_load(:active_record) do + self.include_root_in_json = false +end diff --git a/config/locales/en.yml b/config/locales/en.yml index 513adf9..179c14c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,8 +1,5 @@ # Sample localization file for English. Add more files in this directory for other locales. -# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. +# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. en: hello: "Hello world" - time: - formats: - default: "%a, %d %b %Y %H:%M:%S" \ No newline at end of file