aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorJon Moss <me@jonathanmoss.me>2017-05-02 15:37:06 -0400
committerJon Moss <me@jonathanmoss.me>2017-05-02 17:25:38 -0400
commit8d64cd86db1bc5e1ad119d13eb14f94726a0765f (patch)
tree8e3c6148597402a3dd17f098481ef8631b1c72f0 /activerecord/test/models
parent39a2e1465e15d1da56ba1f4ed14fd38740bd86d4 (diff)
downloadrails-8d64cd86db1bc5e1ad119d13eb14f94726a0765f.tar.gz
rails-8d64cd86db1bc5e1ad119d13eb14f94726a0765f.tar.bz2
rails-8d64cd86db1bc5e1ad119d13eb14f94726a0765f.zip
Add type caster to `RuntimeReflection#alias_name`
Since we have been using this `Arel::Table` since 111ccc832bc977b15af12c14e7ca078dad2d4373, in order to properly handle queries, it's important that we properly type cast arguments.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/author.rb1
-rw-r--r--activerecord/test/models/book.rb2
2 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb
index fab613afd1..2d9cba77e0 100644
--- a/activerecord/test/models/author.rb
+++ b/activerecord/test/models/author.rb
@@ -106,6 +106,7 @@ class Author < ActiveRecord::Base
has_many :tags_with_primary_key, through: :posts
has_many :books
+ has_many :unpublished_books, -> { where(status: [:proposed, :written]) }, class_name: "Book"
has_many :subscriptions, through: :books
has_many :subscribers, -> { order("subscribers.nick") }, through: :subscriptions
has_many :distinct_subscribers, -> { select("DISTINCT subscribers.*").order("subscribers.nick") }, through: :subscriptions, source: :subscriber
diff --git a/activerecord/test/models/book.rb b/activerecord/test/models/book.rb
index 17bf3fbcb4..5f8a8a96dd 100644
--- a/activerecord/test/models/book.rb
+++ b/activerecord/test/models/book.rb
@@ -1,5 +1,5 @@
class Book < ActiveRecord::Base
- has_many :authors
+ belongs_to :author
has_many :citations, foreign_key: "book1_id"
has_many :references, -> { distinct }, through: :citations, source: :reference_of