From 6982e0cb32e04db139e0fa1ca335f074b2c8d033 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Thu, 8 Sep 2011 02:40:59 +0400 Subject: [PATCH] Upgrade to 3.1 step 1 --- Gemfile | 3 +- Gemfile.lock | 131 ++++++++++++++----------- config/application.rb | 18 ++-- config/environments/development.rb | 10 +- config/environments/production.rb | 35 ++++--- config/environments/test.rb | 9 +- config/initializers/secret_token.rb | 2 +- config/initializers/session_store.rb | 2 +- config/initializers/wrap_parameters.rb | 14 +++ config/locales/en.yml | 2 +- config/routes.rb | 2 +- 11 files changed, 142 insertions(+), 86 deletions(-) create mode 100644 config/initializers/wrap_parameters.rb diff --git a/Gemfile b/Gemfile index c4d850c..3e4005a 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'http://rubygems.org' -gem 'rails', '3.0.9' +gem 'rails', '3.1.0' gem 'json' @@ -21,4 +21,5 @@ end group :production do gem 'pg' + gem 'uglifier' end \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index c97dfb3..0cafa1b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -18,93 +18,106 @@ GIT GEM remote: http://rubygems.org/ specs: - abstract (1.0.0) - actionmailer (3.0.9) - actionpack (= 3.0.9) - mail (~> 2.2.19) - actionpack (3.0.9) - activemodel (= 3.0.9) - activesupport (= 3.0.9) - builder (~> 2.1.2) - erubis (~> 2.6.6) - i18n (~> 0.5.0) - rack (~> 1.2.1) - rack-mount (~> 0.6.14) - rack-test (~> 0.5.7) - tzinfo (~> 0.3.23) - activemodel (3.0.9) - activesupport (= 3.0.9) - builder (~> 2.1.2) - i18n (~> 0.5.0) - activerecord (3.0.9) - activemodel (= 3.0.9) - activesupport (= 3.0.9) - arel (~> 2.0.10) - tzinfo (~> 0.3.23) - activeresource (3.0.9) - activemodel (= 3.0.9) - activesupport (= 3.0.9) - activesupport (3.0.9) - arel (2.0.10) + actionmailer (3.1.0) + actionpack (= 3.1.0) + mail (~> 2.3.0) + actionpack (3.1.0) + activemodel (= 3.1.0) + activesupport (= 3.1.0) + builder (~> 3.0.0) + erubis (~> 2.7.0) + i18n (~> 0.6) + rack (~> 1.3.2) + rack-cache (~> 1.0.3) + rack-mount (~> 0.8.2) + rack-test (~> 0.6.1) + sprockets (~> 2.0.0) + activemodel (3.1.0) + activesupport (= 3.1.0) + bcrypt-ruby (~> 3.0.0) + builder (~> 3.0.0) + i18n (~> 0.6) + activerecord (3.1.0) + activemodel (= 3.1.0) + activesupport (= 3.1.0) + arel (~> 2.2.1) + tzinfo (~> 0.3.29) + activeresource (3.1.0) + activemodel (= 3.1.0) + activesupport (= 3.1.0) + activesupport (3.1.0) + multi_json (~> 1.0) + arel (2.2.1) awesome_print (0.4.0) barista (1.2.1) coffee-script (~> 2.2) - builder (2.1.2) + bcrypt-ruby (3.0.0) + builder (3.0.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.1.1) + coffee-script-source (1.1.2) crack (0.1.8) daemons (1.1.4) delayed_job (2.1.4) activesupport (~> 3.0) daemons - erubis (2.6.6) - abstract (>= 1.0.0) - execjs (1.2.0) + erubis (2.7.0) + execjs (1.2.4) multi_json (~> 1.0) - hashie (1.0.0) + hashie (1.1.0) + hike (1.2.1) httparty (0.7.8) crack (= 0.1.8) - i18n (0.5.0) - json (1.5.3) + i18n (0.6.0) + json (1.5.4) libv8 (3.3.10.2) - mail (2.2.19) - activesupport (>= 2.3.6) + mail (2.3.0) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.16) multi_json (1.0.3) pg (0.11.0) - polyglot (0.3.1) - rack (1.2.3) - rack-mount (0.6.14) + polyglot (0.3.2) + rack (1.3.2) + rack-cache (1.0.3) + rack (>= 0.4) + rack-mount (0.8.3) rack (>= 1.0.0) - rack-test (0.5.7) + rack-ssl (1.3.2) + rack + rack-test (0.6.1) rack (>= 1.0) - rails (3.0.9) - actionmailer (= 3.0.9) - actionpack (= 3.0.9) - activerecord (= 3.0.9) - activeresource (= 3.0.9) - activesupport (= 3.0.9) + rails (3.1.0) + actionmailer (= 3.1.0) + actionpack (= 3.1.0) + activerecord (= 3.1.0) + activeresource (= 3.1.0) + activesupport (= 3.1.0) bundler (~> 1.0) - railties (= 3.0.9) - railties (3.0.9) - actionpack (= 3.0.9) - activesupport (= 3.0.9) + railties (= 3.1.0) + railties (3.1.0) + actionpack (= 3.1.0) + activesupport (= 3.1.0) + rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) - thor (~> 0.14.4) + thor (~> 0.14.6) rake (0.9.2) - rdoc (3.8) - sass (3.1.3) - sqlite3 (1.3.3) - therubyracer (0.9.2) + rdoc (3.9.4) + sass (3.1.7) + sprockets (2.0.0) + hike (~> 1.2) + rack (~> 1.0) + tilt (!= 1.3.0, ~> 1.1) + sqlite3 (1.3.4) + therubyracer (0.9.4) libv8 (~> 3.3.10) thor (0.14.6) - treetop (1.4.9) + tilt (1.3.3) + treetop (1.4.10) + polyglot polyglot (>= 0.3.1) tzinfo (0.3.29) xml-simple (1.1.0) @@ -121,7 +134,7 @@ DEPENDENCIES lastfm! musicbrainz-ruby! pg - rails (= 3.0.9) + rails (= 3.1.0) sass sqlite3 therubyracer diff --git a/config/application.rb b/config/application.rb index b716dd1..744b756 100644 --- a/config/application.rb +++ b/config/application.rb @@ -2,9 +2,12 @@ require File.expand_path('../boot', __FILE__) 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 Beathaven class Application < Rails::Application @@ -30,13 +33,16 @@ module Beathaven # 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/environments/development.rb b/config/environments/development.rb index 9fceffd..a09c20b 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -3,7 +3,7 @@ Beathaven::Application.configure do # 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. @@ -11,7 +11,6 @@ Beathaven::Application.configure do # Show full error reports and disable caching config.consider_all_requests_local = true - config.action_view.debug_rjs = true config.action_controller.perform_caching = false # Don't care if the mailer can't send @@ -22,5 +21,10 @@ Beathaven::Application.configure do # 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 11eadc7..aa46c6d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,7 +1,6 @@ Beathaven::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 @@ Beathaven::Application.configure do config.consider_all_requests_local = false config.action_controller.perform_caching = true + # 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 + + # Defaults to Rails.root.join("public/assets") + # config.assets.manifest = YOUR_PATH + # Specifies the header that your server uses for sending files - config.action_dispatch.x_sendfile_header = "X-Sendfile" + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx - # For nginx: - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' - - # If you have no front-end server that supports something like X-Sendfile, - # just comment this out and Rails will serve the files + # 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 @@ Beathaven::Application.configure do # 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 29a7bd7..0f56876 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -7,7 +7,11 @@ Beathaven::Application.configure do # 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 @@ -32,4 +36,7 @@ Beathaven::Application.configure do # Print deprecation notices to the stderr config.active_support.deprecation = :stderr + + # Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets + config.assets.allow_debugging = true end diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index 75c1930..54e093c 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. -Beathaven::Application.config.secret_token = '9f7bfb8b5bebe7befaa38b67e70694dc98c19780eb161b75b1c7251a93874c27138865f5cc3319a72c244560c74994eb69f193f17333943f2a18b867389c48c7' +Beathaven::Application.config.secret_token = 'dfe93b51a8732e4060714fe1a7040bbf708cc724bea9dd91cba2ba4017c222b64240626eb3b71918fab0ea224e9c9b851e60bf8a57f7a4c2976dee14bcdda6ac' diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 3078eb0..cb3e1a2 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. -Beathaven::Application.config.session_store :cookie_store, :key => '_beathaven_session' +Beathaven::Application.config.session_store :cookie_store, key: '_beathaven_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 a747bfa..179c14c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,5 +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" diff --git a/config/routes.rb b/config/routes.rb index 37e66ec..920585a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -48,7 +48,7 @@ Beathaven::Application.routes.draw do # You can have the root of your site routed with "root" # just remember to delete public/index.html. - # root :to => "welcome#index" + # root :to => 'welcome#index' # See how all your routes lay out with "rake routes"