diff options
-rw-r--r-- | Gemfile | 3 | ||||
-rw-r--r-- | Gemfile.lock | 11 | ||||
-rw-r--r-- | activerecord/CHANGELOG.md | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 3 | ||||
-rw-r--r-- | activerecord/lib/active_record/table_metadata.rb | 6 | ||||
-rw-r--r-- | activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb | 6 | ||||
-rw-r--r-- | activerecord/test/models/user.rb | 6 | ||||
-rw-r--r-- | activerecord/test/schema/schema.rb | 5 | ||||
-rw-r--r-- | guides/source/getting_started.md | 33 |
9 files changed, 52 insertions, 25 deletions
@@ -27,6 +27,9 @@ gem 'uglifier', '>= 1.3.0', require: false # Track stable branch of sass because it doesn't have circular require warnings. gem 'sass', github: 'sass/sass', branch: 'stable', require: false +# FIXME: Remove this fork after https://github.com/nex3/rb-inotify/pull/49 is fixed. +gem 'rb-inotify', github: 'matthewd/rb-inotify', branch: 'close-handling', require: false + group :doc do gem 'sdoc', '~> 0.4.0' gem 'redcarpet', '~> 3.2.3', platforms: :ruby diff --git a/Gemfile.lock b/Gemfile.lock index 0a3d91ca29..cf8bb0fec9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -22,6 +22,14 @@ GIT delayed_job (>= 3.0, < 5) GIT + remote: git://github.com/matthewd/rb-inotify.git + revision: 90553518d1fb79aedc98a3036c59bd2b6731ac40 + branch: close-handling + specs: + rb-inotify (0.9.7) + ffi (>= 0.5.0) + +GIT remote: git://github.com/resque/resque.git revision: 06036388ec61e573c761ac5a25a2ef3c76537ec7 specs: @@ -254,8 +262,6 @@ GEM loofah (~> 2.0) rake (11.1.2) rb-fsevent (0.9.7) - rb-inotify (0.9.7) - ffi (>= 0.5.0) rdoc (4.2.2) json (~> 1.4) redcarpet (3.2.3) @@ -381,6 +387,7 @@ DEPENDENCIES rack-cache (~> 1.2) rails! rake (>= 11.1) + rb-inotify! redcarpet (~> 3.2.3) redis resque! diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index d3e1cf68a2..14a6c3c9f7 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,7 @@ +* Fix the SELECT statement in `#table_comment` for MySQL. + + *Takeshi Akima* + * Virtual attributes will no longer raise when read on models loaded from the database diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index 25e3939b62..01395d8ceb 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -413,7 +413,8 @@ module ActiveRecord select_value(<<-SQL.strip_heredoc, 'SCHEMA') SELECT table_comment FROM information_schema.tables - WHERE table_name=#{quote(table_name)} + WHERE table_schema=#{quote(current_database)} + AND table_name=#{quote(table_name)} SQL end diff --git a/activerecord/lib/active_record/table_metadata.rb b/activerecord/lib/active_record/table_metadata.rb index a1326aa359..5fe0d8b5e4 100644 --- a/activerecord/lib/active_record/table_metadata.rb +++ b/activerecord/lib/active_record/table_metadata.rb @@ -42,11 +42,11 @@ module ActiveRecord end def associated_table(table_name) - return self if table_name == arel_table.name - association = klass._reflect_on_association(table_name) || klass._reflect_on_association(table_name.singularize) - if association && !association.polymorphic? + if !association && table_name == arel_table.name + return self + elsif association && !association.polymorphic? association_klass = association.klass arel_table = association_klass.arel_table.alias(table_name) else diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb index e27f16b6e4..a959f3c06a 100644 --- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb @@ -19,6 +19,7 @@ require 'models/professor' require 'models/treasure' require 'models/price_estimate' require 'models/club' +require 'models/user' require 'models/member' require 'models/membership' require 'models/sponsor' @@ -995,4 +996,9 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase Project.first.developers_required_by_default.create!(name: "Sean", salary: 50000) end end + + def test_association_name_is_the_same_as_join_table_name + user = User.create! + assert_nothing_raised { user.jobs_pool.clear } + end end diff --git a/activerecord/test/models/user.rb b/activerecord/test/models/user.rb index f5dc93e994..97107a35a0 100644 --- a/activerecord/test/models/user.rb +++ b/activerecord/test/models/user.rb @@ -1,6 +1,12 @@ +require 'models/job' + class User < ActiveRecord::Base has_secure_token has_secure_token :auth_token + + has_and_belongs_to_many :jobs_pool, + class_name: Job, + join_table: 'jobs_pool' end class UserWithNotification < User diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb index 2f2993ce18..a5155e9cdb 100644 --- a/activerecord/test/schema/schema.rb +++ b/activerecord/test/schema/schema.rb @@ -390,6 +390,11 @@ ActiveRecord::Schema.define do t.integer :ideal_reference_id end + create_table :jobs_pool, force: true, id: false do |t| + t.references :job, null: false, index: true + t.references :user, null: false, index: true + end + create_table :keyboards, force: true, id: false do |t| t.primary_key :key_number t.string :name diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index 0f1c3735e8..73dbb2bc40 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -465,29 +465,24 @@ The first part identifies which template is missing. In this case, it's the then it will attempt to load a template called `application/new`. It looks for one here because the `ArticlesController` inherits from `ApplicationController`. -The next part of the message contains a hash. The `:locale` key in this hash -simply indicates which spoken language template should be retrieved. By default, -this is the English - or "en" - template. The next key, `:formats` specifies the -format of the template to be served in response. The default format is `:html`, and -so Rails is looking for an HTML template. The final key, `:handlers`, is telling -us what _template handlers_ could be used to render our template. `:erb` is most -commonly used for HTML templates, `:builder` is used for XML templates, and -`:coffee` uses CoffeeScript to build JavaScript templates. - -The message also contains `request.formats` which specifies the format of template to be -served in response. It is set to `text/html` as we requested this page via browser, so Rails -is looking for an HTML template. +The next part of the message contains `request.formats` which specifies +the format of template to be served in response. It is set to `text/html` as we +requested this page via browser, so Rails is looking for an HTML template. +`request.variants` specifies what kind of physical devices would be served by +the response and helps Rails determine which template to use in the response. +It is empty because no information has been provided. The simplest template that would work in this case would be one located at `app/views/articles/new.html.erb`. The extension of this file name is important: the first extension is the _format_ of the template, and the second extension -is the _handler_ that will be used. Rails is attempting to find a template -called `articles/new` within `app/views` for the application. The format for -this template can only be `html` and the handler must be one of `erb`, -`builder` or `coffee`. `:erb` is most commonly used for HTML templates, `:builder` is -used for XML templates, and `:coffee` uses CoffeeScript to build JavaScript templates. -Because you want to create a new HTML form, you will be -using the `ERB` language which is designed to embed Ruby in HTML. +is the _handler_ that will be used to render the template. Rails is attempting +to find a template called `articles/new` within `app/views` for the +application. The format for this template can only be `html` and the default +handler for HTML is `erb`. Rails uses other handlers for other formats. +`builder` handler is used to build XML templates and `coffee` handler uses +CoffeeScript to build JavaScript templates. Because you want to create a new +HTML form, you will be using the `ERB` language which is designed to embed Ruby +in HTML. Therefore the file should be called `articles/new.html.erb` and needs to be located inside the `app/views` directory of the application. |