Created
May 21, 2013 12:28
-
-
Save senny/5619425 to your computer and use it in GitHub Desktop.
Changes to https://github.com/ciscou/eager_load_polymorphic_error_bug_demo to solve https://github.com/rails/rails/issues/10136#issuecomment-16793568
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Gemfile b/Gemfile | |
index 9a2ccae..e210472 100644 | |
--- a/Gemfile | |
+++ b/Gemfile | |
@@ -1,6 +1,6 @@ | |
source 'https://rubygems.org' | |
-gem 'rails', '3.2.13' | |
+gem 'rails', '4.0.0.rc1' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
@@ -11,8 +11,9 @@ gem 'sqlite3' | |
# Gems used only for assets and not required | |
# in production environments by default. | |
group :assets do | |
- gem 'sass-rails', '~> 3.2.3' | |
- gem 'coffee-rails', '~> 3.2.1' | |
+ gem 'sprockets-rails', github: 'rails/sprockets-rails' | |
+ gem 'sass-rails', github: 'rails/sass-rails' | |
+ gem 'coffee-rails', github: 'rails/coffee-rails' | |
# See https://github.com/sstephenson/execjs#readme for more supported runtimes | |
# gem 'therubyracer', :platforms => :ruby | |
@@ -20,7 +21,7 @@ group :assets do | |
gem 'uglifier', '>= 1.0.3' | |
end | |
-gem 'jquery-rails' | |
+gem 'jquery-rails', github: "rails/jquery-rails" | |
# To use ActiveModel has_secure_password | |
# gem 'bcrypt-ruby', '~> 3.0.0' | |
diff --git a/Gemfile.lock b/Gemfile.lock | |
index 60f0a8d..141ef87 100644 | |
--- a/Gemfile.lock | |
+++ b/Gemfile.lock | |
@@ -1,38 +1,67 @@ | |
+GIT | |
+ remote: git://github.com/rails/coffee-rails.git | |
+ revision: cbc4a6f571e87f68d272b9a377db3fb3307464ab | |
+ specs: | |
+ coffee-rails (4.0.0) | |
+ coffee-script (>= 2.2.0) | |
+ railties (>= 4.0.0.beta, < 5.0) | |
+ | |
+GIT | |
+ remote: git://github.com/rails/jquery-rails.git | |
+ revision: 28ee0ef4c8486c1e331bbc7f7d0ccbf1b0631af5 | |
+ specs: | |
+ jquery-rails (2.2.1) | |
+ railties (>= 3.0, < 5.0) | |
+ thor (>= 0.14, < 2.0) | |
+ | |
+GIT | |
+ remote: git://github.com/rails/sass-rails.git | |
+ revision: 33799418f104c961b1ce41452e77cf1e04930755 | |
+ specs: | |
+ sass-rails (4.0.0.rc1) | |
+ railties (>= 4.0.0.beta, < 5.0) | |
+ sass (>= 3.1.10) | |
+ sprockets-rails (~> 2.0.0.rc4) | |
+ | |
+GIT | |
+ remote: git://github.com/rails/sprockets-rails.git | |
+ revision: 733fedff9da3997f1b98760b948114255f53860b | |
+ specs: | |
+ sprockets-rails (2.0.0.rc4) | |
+ actionpack (>= 3.0) | |
+ activesupport (>= 3.0) | |
+ sprockets (~> 2.8) | |
+ | |
GEM | |
remote: https://rubygems.org/ | |
specs: | |
- actionmailer (3.2.13) | |
- actionpack (= 3.2.13) | |
+ actionmailer (4.0.0.rc1) | |
+ actionpack (= 4.0.0.rc1) | |
mail (~> 2.5.3) | |
- actionpack (3.2.13) | |
- activemodel (= 3.2.13) | |
- activesupport (= 3.2.13) | |
- builder (~> 3.0.0) | |
+ actionpack (4.0.0.rc1) | |
+ activesupport (= 4.0.0.rc1) | |
+ builder (~> 3.1.0) | |
erubis (~> 2.7.0) | |
- journey (~> 1.0.4) | |
- rack (~> 1.4.5) | |
- rack-cache (~> 1.2) | |
- rack-test (~> 0.6.1) | |
- sprockets (~> 2.2.1) | |
- activemodel (3.2.13) | |
- activesupport (= 3.2.13) | |
- builder (~> 3.0.0) | |
- activerecord (3.2.13) | |
- activemodel (= 3.2.13) | |
- activesupport (= 3.2.13) | |
- arel (~> 3.0.2) | |
- tzinfo (~> 0.3.29) | |
- activeresource (3.2.13) | |
- activemodel (= 3.2.13) | |
- activesupport (= 3.2.13) | |
- activesupport (3.2.13) | |
- i18n (= 0.6.1) | |
- multi_json (~> 1.0) | |
- arel (3.0.2) | |
- builder (3.0.4) | |
- coffee-rails (3.2.2) | |
- coffee-script (>= 2.2.0) | |
- railties (~> 3.2.0) | |
+ rack (~> 1.5.2) | |
+ rack-test (~> 0.6.2) | |
+ activemodel (4.0.0.rc1) | |
+ activesupport (= 4.0.0.rc1) | |
+ builder (~> 3.1.0) | |
+ activerecord (4.0.0.rc1) | |
+ activemodel (= 4.0.0.rc1) | |
+ activerecord-deprecated_finders (~> 1.0.2) | |
+ activesupport (= 4.0.0.rc1) | |
+ arel (~> 4.0.0) | |
+ activerecord-deprecated_finders (1.0.2) | |
+ activesupport (4.0.0.rc1) | |
+ i18n (~> 0.6, >= 0.6.4) | |
+ minitest (~> 4.2) | |
+ multi_json (~> 1.3) | |
+ thread_safe (~> 0.1) | |
+ tzinfo (~> 0.3.37) | |
+ arel (4.0.0) | |
+ atomic (1.1.9) | |
+ builder (3.1.4) | |
coffee-script (2.2.0) | |
coffee-script-source | |
execjs | |
@@ -40,63 +69,48 @@ GEM | |
erubis (2.7.0) | |
execjs (1.4.0) | |
multi_json (~> 1.0) | |
- hike (1.2.1) | |
- i18n (0.6.1) | |
- journey (1.0.4) | |
- jquery-rails (2.2.1) | |
- railties (>= 3.0, < 5.0) | |
- thor (>= 0.14, < 2.0) | |
- json (1.7.7) | |
- mail (2.5.3) | |
- i18n (>= 0.4.0) | |
+ hike (1.2.2) | |
+ i18n (0.6.4) | |
+ mail (2.5.4) | |
mime-types (~> 1.16) | |
treetop (~> 1.4.8) | |
- mime-types (1.22) | |
- multi_json (1.7.2) | |
+ mime-types (1.23) | |
+ minitest (4.7.4) | |
+ multi_json (1.7.3) | |
polyglot (0.3.3) | |
- rack (1.4.5) | |
- rack-cache (1.2) | |
- rack (>= 0.4) | |
- rack-ssl (1.3.3) | |
- rack | |
+ rack (1.5.2) | |
rack-test (0.6.2) | |
rack (>= 1.0) | |
- rails (3.2.13) | |
- actionmailer (= 3.2.13) | |
- actionpack (= 3.2.13) | |
- activerecord (= 3.2.13) | |
- activeresource (= 3.2.13) | |
- activesupport (= 3.2.13) | |
- bundler (~> 1.0) | |
- railties (= 3.2.13) | |
- railties (3.2.13) | |
- actionpack (= 3.2.13) | |
- activesupport (= 3.2.13) | |
- rack-ssl (~> 1.3.2) | |
+ rails (4.0.0.rc1) | |
+ actionmailer (= 4.0.0.rc1) | |
+ actionpack (= 4.0.0.rc1) | |
+ activerecord (= 4.0.0.rc1) | |
+ activesupport (= 4.0.0.rc1) | |
+ bundler (>= 1.3.0, < 2.0) | |
+ railties (= 4.0.0.rc1) | |
+ sprockets-rails (~> 2.0.0.rc4) | |
+ railties (4.0.0.rc1) | |
+ actionpack (= 4.0.0.rc1) | |
+ activesupport (= 4.0.0.rc1) | |
rake (>= 0.8.7) | |
- rdoc (~> 3.4) | |
- thor (>= 0.14.6, < 2.0) | |
+ thor (>= 0.18.1, < 2.0) | |
rake (10.0.4) | |
- rdoc (3.12.2) | |
- json (~> 1.4) | |
- sass (3.2.7) | |
- sass-rails (3.2.6) | |
- railties (~> 3.2.0) | |
- sass (>= 3.1.10) | |
- tilt (~> 1.3) | |
- sprockets (2.2.2) | |
+ sass (3.2.9) | |
+ sprockets (2.9.3) | |
hike (~> 1.2) | |
multi_json (~> 1.0) | |
rack (~> 1.0) | |
tilt (~> 1.1, != 1.3.0) | |
sqlite3 (1.3.7) | |
thor (0.18.1) | |
- tilt (1.3.6) | |
+ thread_safe (0.1.0) | |
+ atomic | |
+ tilt (1.4.1) | |
treetop (1.4.12) | |
polyglot | |
polyglot (>= 0.3.1) | |
tzinfo (0.3.37) | |
- uglifier (1.3.0) | |
+ uglifier (2.1.1) | |
execjs (>= 0.3.0) | |
multi_json (~> 1.0, >= 1.0.2) | |
@@ -104,9 +118,10 @@ PLATFORMS | |
ruby | |
DEPENDENCIES | |
- coffee-rails (~> 3.2.1) | |
- jquery-rails | |
- rails (= 3.2.13) | |
- sass-rails (~> 3.2.3) | |
+ coffee-rails! | |
+ jquery-rails! | |
+ rails (= 4.0.0.rc1) | |
+ sass-rails! | |
+ sprockets-rails! | |
sqlite3 | |
uglifier (>= 1.0.3) | |
diff --git a/app/models/address.rb b/app/models/address.rb | |
index 7a7fb10..435cbe5 100644 | |
--- a/app/models/address.rb | |
+++ b/app/models/address.rb | |
@@ -1,6 +1,4 @@ | |
class Address < ActiveRecord::Base | |
- attr_accessible :street | |
- | |
belongs_to :addressable, polymorphic: true | |
scope :by_street, ->(q) { where(street: q) } | |
diff --git a/app/models/company.rb b/app/models/company.rb | |
index f0b4e23..a6b3581 100644 | |
--- a/app/models/company.rb | |
+++ b/app/models/company.rb | |
@@ -1,5 +1,3 @@ | |
class Company < ActiveRecord::Base | |
- attr_accessible :name | |
- | |
has_one :address, as: :addressable | |
end | |
diff --git a/app/models/person.rb b/app/models/person.rb | |
index 1fabc75..2e92f83 100644 | |
--- a/app/models/person.rb | |
+++ b/app/models/person.rb | |
@@ -1,5 +1,3 @@ | |
class Person < ActiveRecord::Base | |
- attr_accessible :name | |
- | |
has_one :address, as: :addressable | |
end | |
diff --git a/config/application.rb b/config/application.rb | |
index f26e57b..80c0ac6 100644 | |
--- a/config/application.rb | |
+++ b/config/application.rb | |
@@ -2,12 +2,9 @@ require File.expand_path('../boot', __FILE__) | |
require 'rails/all' | |
-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 | |
+# Require the gems listed in Gemfile, including any gems | |
+# you've limited to :test, :development, or :production. | |
+Bundler.require(:default, Rails.env) | |
module EagerLoadPolymorphicErrorBugDemo | |
class Application < Rails::Application | |
@@ -15,16 +12,6 @@ module EagerLoadPolymorphicErrorBugDemo | |
# Application configuration should go into files in config/initializers | |
# -- all .rb files in that directory are automatically loaded. | |
- # Custom directories with classes and modules you want to be autoloadable. | |
- # config.autoload_paths += %W(#{config.root}/extras) | |
- | |
- # Only load the plugins named here, in the order given (default is alphabetical). | |
- # :all can be used as a placeholder for all plugins not explicitly named. | |
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ] | |
- | |
- # Activate observers that should always be running. | |
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer | |
- | |
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. | |
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. | |
# config.time_zone = 'Central Time (US & Canada)' | |
@@ -33,30 +20,6 @@ module EagerLoadPolymorphicErrorBugDemo | |
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] | |
# config.i18n.default_locale = :de | |
- # 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 escaping HTML in JSON. | |
- config.active_support.escape_html_entities_in_json = true | |
- | |
- # Use SQL instead of Active Record's schema dumper when creating the database. | |
- # This is necessary if your schema can't be completely dumped by the schema dumper, | |
- # like if you have constraints or database-specific column types | |
- # config.active_record.schema_format = :sql | |
- | |
- # Enforce whitelist mode for mass assignment. | |
- # This will create an empty whitelist of attributes available for mass-assignment for all models | |
- # in your app. As such, your models will need to explicitly whitelist or blacklist accessible | |
- # parameters by using an attr_accessible or attr_protected declaration. | |
- config.active_record.whitelist_attributes = true | |
- | |
- # 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' | |
+ config.active_record.disable_implicit_join_references = true | |
end | |
end | |
diff --git a/config/boot.rb b/config/boot.rb | |
index 4489e58..3596736 100644 | |
--- a/config/boot.rb | |
+++ b/config/boot.rb | |
@@ -1,5 +1,3 @@ | |
-require 'rubygems' | |
- | |
# Set up gems listed in the Gemfile. | |
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) | |
diff --git a/config/environment.rb b/config/environment.rb | |
index 4ea8826..86061f2 100644 | |
--- a/config/environment.rb | |
+++ b/config/environment.rb | |
@@ -1,5 +1,5 @@ | |
-# Load the rails application | |
+# Load the rails application. | |
require File.expand_path('../application', __FILE__) | |
-# Initialize the rails application | |
+# Initialize the rails application. | |
EagerLoadPolymorphicErrorBugDemo::Application.initialize! | |
diff --git a/config/environments/development.rb b/config/environments/development.rb | |
index 0bdec28..f3bc763 100644 | |
--- a/config/environments/development.rb | |
+++ b/config/environments/development.rb | |
@@ -1,37 +1,29 @@ | |
EagerLoadPolymorphicErrorBugDemo::Application.configure do | |
- # Settings specified here will take precedence over those in config/application.rb | |
+ # Settings specified here will take precedence over those in config/application.rb. | |
# 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 web server when you make code changes. | |
config.cache_classes = false | |
- # Log error messages when you accidentally call methods on nil. | |
- config.whiny_nils = true | |
+ # Do not eager load code on boot. | |
+ config.eager_load = false | |
- # Show full error reports and disable caching | |
+ # Show full error reports and disable caching. | |
config.consider_all_requests_local = true | |
config.action_controller.perform_caching = false | |
- # Don't care if the mailer can't send | |
+ # Don't care if the mailer can't send. | |
config.action_mailer.raise_delivery_errors = false | |
- # Print deprecation notices to the Rails logger | |
+ # Print deprecation notices to the Rails logger. | |
config.active_support.deprecation = :log | |
- # Only use best-standards-support built into browsers | |
- config.action_dispatch.best_standards_support = :builtin | |
+ # Raise an error on page load if there are pending migrations | |
+ config.active_record.migration_error = :page_load | |
- # Raise exception on mass assignment protection for Active Record models | |
- config.active_record.mass_assignment_sanitizer = :strict | |
- | |
- # Log the query plan for queries taking more than this (works | |
- # with SQLite, MySQL, and PostgreSQL) | |
- config.active_record.auto_explain_threshold_in_seconds = 0.5 | |
- | |
- # Do not compress assets | |
- config.assets.compress = false | |
- | |
- # Expands the lines which load the assets | |
+ # Debug mode disables concatenation and preprocessing of assets. | |
+ # This option may cause significant delays in view rendering with a large | |
+ # number of complex assets. | |
config.assets.debug = true | |
end | |
diff --git a/config/environments/production.rb b/config/environments/production.rb | |
index 7be23d8..b05269f 100644 | |
--- a/config/environments/production.rb | |
+++ b/config/environments/production.rb | |
@@ -1,67 +1,80 @@ | |
EagerLoadPolymorphicErrorBugDemo::Application.configure do | |
- # Settings specified here will take precedence over those in config/application.rb | |
+ # Settings specified here will take precedence over those in config/application.rb. | |
- # Code is not reloaded between requests | |
+ # Code is not reloaded between requests. | |
config.cache_classes = true | |
- # Full error reports are disabled and caching is turned on | |
+ # Eager load code on boot. This eager loads most of Rails and | |
+ # your application in memory, allowing both thread web servers | |
+ # and those relying on copy on write to perform better. | |
+ # Rake tasks automatically ignore this option for performance. | |
+ config.eager_load = true | |
+ | |
+ # Full error reports are disabled and caching is turned on. | |
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) | |
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application | |
+ # Add `rack-cache` to your Gemfile before enabling this. | |
+ # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. | |
+ # config.action_dispatch.rack_cache = 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 | |
+ # Compress JavaScripts and CSS. | |
+ config.assets.js_compressor = :uglifier | |
+ # config.assets.css_compressor = :sass | |
- # Don't fallback to assets pipeline if a precompiled asset is missed | |
+ # Do not fallback to assets pipeline if a precompiled asset is missed. | |
config.assets.compile = false | |
- # Generate digests for assets URLs | |
+ # Generate digests for assets URLs. | |
config.assets.digest = true | |
- # Defaults to nil and saved in location specified by config.assets.prefix | |
- # config.assets.manifest = YOUR_PATH | |
+ # Version of your assets, change this if you want to expire all your assets. | |
+ config.assets.version = '1.0' | |
- # Specifies the header that your server uses for sending 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 | |
+ # Set to :debug to see everything in the log. | |
+ config.log_level = :info | |
- # Prepend all log lines with the following tags | |
+ # Prepend all log lines with the following tags. | |
# config.log_tags = [ :subdomain, :uuid ] | |
- # Use a different logger for distributed setups | |
+ # Use a different logger for distributed setups. | |
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) | |
- # Use a different cache store in production | |
+ # Use a different cache store in production. | |
# config.cache_store = :mem_cache_store | |
- # 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) | |
+ # Precompile additional assets. | |
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. | |
# config.assets.precompile += %w( search.js ) | |
- # Disable delivery errors, bad email addresses will be ignored | |
+ # Ignore bad email addresses and do not raise email delivery errors. | |
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors. | |
# config.action_mailer.raise_delivery_errors = false | |
- # Enable threaded mode | |
- # config.threadsafe! | |
- | |
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to | |
- # the I18n.default_locale when a translation can not be found) | |
+ # the I18n.default_locale when a translation can not be found). | |
config.i18n.fallbacks = true | |
- # Send deprecation notices to registered listeners | |
+ # Send deprecation notices to registered listeners. | |
config.active_support.deprecation = :notify | |
- # Log the query plan for queries taking more than this (works | |
- # with SQLite, MySQL, and PostgreSQL) | |
- # config.active_record.auto_explain_threshold_in_seconds = 0.5 | |
+ # Disable automatic flushing of the log to improve performance. | |
+ # config.autoflush_log = false | |
+ | |
+ # Use default logging formatter so that PID and timestamp are not suppressed. | |
+ config.log_formatter = ::Logger::Formatter.new | |
end | |
diff --git a/config/environments/test.rb b/config/environments/test.rb | |
index c18994f..0a5d7f4 100644 | |
--- a/config/environments/test.rb | |
+++ b/config/environments/test.rb | |
@@ -1,5 +1,5 @@ | |
EagerLoadPolymorphicErrorBugDemo::Application.configure do | |
- # Settings specified here will take precedence over those in config/application.rb | |
+ # Settings specified here will take precedence over those in config/application.rb. | |
# The test environment is used exclusively to run your application's | |
# test suite. You never need to work with it otherwise. Remember that | |
@@ -7,31 +7,30 @@ EagerLoadPolymorphicErrorBugDemo::Application.configure do | |
# and recreated between test runs. Don't rely on the data there! | |
config.cache_classes = true | |
- # Configure static asset server for tests with Cache-Control for performance | |
- config.serve_static_assets = true | |
- config.static_cache_control = "public, max-age=3600" | |
+ # Do not eager load code on boot. This avoids loading your whole application | |
+ # just for the purpose of running a single test. If you are using a tool that | |
+ # preloads Rails for running tests, you may have to set it to true. | |
+ config.eager_load = false | |
- # Log error messages when you accidentally call methods on nil | |
- config.whiny_nils = true | |
+ # Configure static asset server for tests with Cache-Control for performance. | |
+ config.serve_static_assets = true | |
+ config.static_cache_control = "public, max-age=3600" | |
- # Show full error reports and disable caching | |
+ # Show full error reports and disable caching. | |
config.consider_all_requests_local = true | |
config.action_controller.perform_caching = false | |
- # Raise exceptions instead of rendering exception templates | |
+ # Raise exceptions instead of rendering exception templates. | |
config.action_dispatch.show_exceptions = false | |
- # Disable request forgery protection in test environment | |
- config.action_controller.allow_forgery_protection = false | |
+ # Disable request forgery protection in test environment. | |
+ config.action_controller.allow_forgery_protection = false | |
# Tell Action Mailer not to deliver emails to the real world. | |
# The :test delivery method accumulates sent emails in the | |
# ActionMailer::Base.deliveries array. | |
config.action_mailer.delivery_method = :test | |
- # Raise exception on mass assignment protection for Active Record models | |
- config.active_record.mass_assignment_sanitizer = :strict | |
- | |
- # Print deprecation notices to the stderr | |
+ # Print deprecation notices to the stderr. | |
config.active_support.deprecation = :stderr | |
end | |
diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb | |
index 5d8d9be..ac033bf 100644 | |
--- a/config/initializers/inflections.rb | |
+++ b/config/initializers/inflections.rb | |
@@ -1,15 +1,16 @@ | |
# Be sure to restart your server when you modify this file. | |
-# Add new inflection rules using the following format | |
-# (all these examples are active by default): | |
-# ActiveSupport::Inflector.inflections do |inflect| | |
+# Add new inflection rules using the following format. Inflections | |
+# are locale specific, and you may define rules for as many different | |
+# locales as you wish. All of these examples are active by default: | |
+# ActiveSupport::Inflector.inflections(:en) do |inflect| | |
# inflect.plural /^(ox)$/i, '\1en' | |
# inflect.singular /^(ox)en/i, '\1' | |
# inflect.irregular 'person', 'people' | |
# inflect.uncountable %w( fish sheep ) | |
# end | |
-# | |
+ | |
# These inflection rules are supported but not enabled by default: | |
-# ActiveSupport::Inflector.inflections do |inflect| | |
+# ActiveSupport::Inflector.inflections(:en) do |inflect| | |
# inflect.acronym 'RESTful' | |
# end | |
diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb | |
index b1ca76a..0e8f6ba 100644 | |
--- a/config/initializers/secret_token.rb | |
+++ b/config/initializers/secret_token.rb | |
@@ -1,7 +1,12 @@ | |
# Be sure to restart your server when you modify this file. | |
-# Your secret key for verifying the integrity of signed cookies. | |
+# Your secret key is used for verifying the integrity of signed cookies. | |
# 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. | |
-EagerLoadPolymorphicErrorBugDemo::Application.config.secret_token = '2c50778fa8384aba10b4ae413ffdf7057f530d87cc3d4e558882625f510b156f2940c617903a645e6a92dde70c0c76b3529c712c6339c773b11bceac6dbbaeee' | |
+# You can use `rake secret` to generate a secure secret key. | |
+ | |
+# Make sure your secret_key_base is kept private | |
+# if you're sharing your code publicly. | |
+EagerLoadPolymorphicErrorBugDemo::Application.config.secret_key_base = 'c3a0e5581d7e08e4d86de30f558812930f7eaf7aa96866f251c79cb5b6b8b6acf546d093a50e44aa685508d32a6eb4ddf01918d793b56a9f2fda8472ded3b6a5' | |
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb | |
index 3de3fd4..a62064e 100644 | |
--- a/config/initializers/session_store.rb | |
+++ b/config/initializers/session_store.rb | |
@@ -1,8 +1,3 @@ | |
# Be sure to restart your server when you modify this file. | |
EagerLoadPolymorphicErrorBugDemo::Application.config.session_store :cookie_store, key: '_eager_load_polymorphic_error_bug_demo_session' | |
- | |
-# Use the database for sessions instead of the cookie-based default, | |
-# which shouldn't be used to store highly confidential information | |
-# (create the session table with "rails generate session_migration") | |
-# EagerLoadPolymorphicErrorBugDemo::Application.config.session_store :active_record_store | |
diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb | |
index 999df20..33725e9 100644 | |
--- a/config/initializers/wrap_parameters.rb | |
+++ b/config/initializers/wrap_parameters.rb | |
@@ -1,14 +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] | |
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters) | |
end | |
-# Disable root element in JSON by default. | |
-ActiveSupport.on_load(:active_record) do | |
- self.include_root_in_json = false | |
-end | |
+# To enable root element in JSON for ActiveRecord objects. | |
+# ActiveSupport.on_load(:active_record) do | |
+# self.include_root_in_json = true | |
+# end | |
diff --git a/config/locales/en.yml b/config/locales/en.yml | |
index 179c14c..0653957 100644 | |
--- a/config/locales/en.yml | |
+++ b/config/locales/en.yml | |
@@ -1,5 +1,23 @@ | |
-# Sample localization file for English. Add more files in this directory for other locales. | |
-# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. | |
+# Files in the config/locales directory are used for internationalization | |
+# and are automatically loaded by Rails. If you want to use locales other | |
+# than English, add the necessary files in this directory. | |
+# | |
+# To use the locales, use `I18n.t`: | |
+# | |
+# I18n.t 'hello' | |
+# | |
+# In views, this is aliased to just `t`: | |
+# | |
+# <%= t('hello') %> | |
+# | |
+# To use a different locale, set it with `I18n.locale`: | |
+# | |
+# I18n.locale = :es | |
+# | |
+# This would use the information in config/locales/es.yml. | |
+# | |
+# To learn more, please read the Rails Internationalization guide | |
+# available at http://guides.rubyonrails.org/i18n.html. | |
en: | |
hello: "Hello world" | |
diff --git a/config/routes.rb b/config/routes.rb | |
index a2e09c7..b66f11f 100644 | |
--- a/config/routes.rb | |
+++ b/config/routes.rb | |
@@ -1,19 +1,20 @@ | |
EagerLoadPolymorphicErrorBugDemo::Application.routes.draw do | |
- # The priority is based upon order of creation: | |
- # first created -> highest priority. | |
+ # The priority is based upon order of creation: first created -> highest priority. | |
+ # See how all your routes lay out with "rake routes". | |
- # Sample of regular route: | |
- # match 'products/:id' => 'catalog#view' | |
- # Keep in mind you can assign values other than :controller and :action | |
+ # You can have the root of your site routed with "root" | |
+ # root 'welcome#index' | |
+ | |
+ # Example of regular route: | |
+ # get 'products/:id' => 'catalog#view' | |
- # Sample of named route: | |
- # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase | |
- # This route can be invoked with purchase_url(:id => product.id) | |
+ # Example of named route that can be invoked with purchase_url(id: product.id) | |
+ # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase | |
- # Sample resource route (maps HTTP verbs to controller actions automatically): | |
+ # Example resource route (maps HTTP verbs to controller actions automatically): | |
# resources :products | |
- # Sample resource route with options: | |
+ # Example resource route with options: | |
# resources :products do | |
# member do | |
# get 'short' | |
@@ -25,34 +26,24 @@ EagerLoadPolymorphicErrorBugDemo::Application.routes.draw do | |
# end | |
# end | |
- # Sample resource route with sub-resources: | |
+ # Example resource route with sub-resources: | |
# resources :products do | |
# resources :comments, :sales | |
# resource :seller | |
# end | |
- # Sample resource route with more complex sub-resources | |
+ # Example resource route with more complex sub-resources: | |
# resources :products do | |
# resources :comments | |
# resources :sales do | |
- # get 'recent', :on => :collection | |
+ # get 'recent', on: :collection | |
# end | |
# end | |
- # Sample resource route within a namespace: | |
+ # Example resource route within a namespace: | |
# namespace :admin do | |
# # Directs /admin/products/* to Admin::ProductsController | |
# # (app/controllers/admin/products_controller.rb) | |
# resources :products | |
# end | |
- | |
- # You can have the root of your site routed with "root" | |
- # just remember to delete public/index.html. | |
- # root :to => 'welcome#index' | |
- | |
- # See how all your routes lay out with "rake routes" | |
- | |
- # This is a legacy wild controller route that's not recommended for RESTful applications. | |
- # Note: This route will make all actions in every controller accessible via GET requests. | |
- # match ':controller(/:action(/:id))(.:format)' | |
end | |
diff --git a/db/schema.rb b/db/schema.rb | |
index 2590b6f..59d6599 100644 | |
--- a/db/schema.rb | |
+++ b/db/schema.rb | |
@@ -9,30 +9,30 @@ | |
# from scratch. The latter is a flawed and unsustainable approach (the more migrations | |
# you'll amass, the slower it'll run and the greater likelihood for issues). | |
# | |
-# It's strongly recommended to check this file into your version control system. | |
+# It's strongly recommended that you check this file into your version control system. | |
-ActiveRecord::Schema.define(:version => 20130405083351) do | |
+ActiveRecord::Schema.define(version: 20130405083351) do | |
- create_table "addresses", :force => true do |t| | |
+ create_table "addresses", force: true do |t| | |
t.integer "addressable_id" | |
t.string "addressable_type" | |
t.string "street" | |
- t.datetime "created_at", :null => false | |
- t.datetime "updated_at", :null => false | |
+ t.datetime "created_at" | |
+ t.datetime "updated_at" | |
end | |
- add_index "addresses", ["addressable_id"], :name => "index_addresses_on_addressable_id" | |
+ add_index "addresses", ["addressable_id"], name: "index_addresses_on_addressable_id" | |
- create_table "companies", :force => true do |t| | |
+ create_table "companies", force: true do |t| | |
t.string "name" | |
- t.datetime "created_at", :null => false | |
- t.datetime "updated_at", :null => false | |
+ t.datetime "created_at" | |
+ t.datetime "updated_at" | |
end | |
- create_table "people", :force => true do |t| | |
+ create_table "people", force: true do |t| | |
t.string "name" | |
- t.datetime "created_at", :null => false | |
- t.datetime "updated_at", :null => false | |
+ t.datetime "created_at" | |
+ t.datetime "updated_at" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment