1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #32717 from tgturner/make-get-and-set-values-public-again

Make get_value public again
This commit is contained in:
Ryuta Kamizono 2018-04-25 20:00:46 +09:00 committed by GitHub
commit c81a7fcf76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 4 deletions

View file

@ -909,11 +909,12 @@ module ActiveRecord
@arel ||= build_arel(aliases)
end
# Returns a relation value with a given name
def get_value(name) # :nodoc:
@values.fetch(name, DEFAULT_VALUES[name])
end
protected
# Returns a relation value with a given name
def get_value(name) # :nodoc:
@values.fetch(name, DEFAULT_VALUES[name])
end
# Sets the relation value with the given name
def set_value(name, value) # :nodoc:

View file

@ -126,5 +126,12 @@ module ActiveRecord
expected = Author.find(1).posts + Post.where(title: "I don't have any comments")
assert_equal expected.sort_by(&:id), actual.sort_by(&:id)
end
def test_or_with_scope_on_association
author = Author.first
assert_nothing_raised do
author.top_posts.or(author.other_top_posts)
end
end
end
end

View file

@ -162,6 +162,9 @@ class Author < ActiveRecord::Base
def extension_method; end
end
has_many :top_posts, -> { order(id: :asc) }, class_name: "Post"
has_many :other_top_posts, -> { order(id: :asc) }, class_name: "Post"
attr_accessor :post_log
after_initialize :set_post_log