method
reader
v5.0.0.1 -
Show latest stable
- Class:
ActiveRecord::Associations::CollectionAssociation
reader(force_reload = false)public
Implements the reader method, e.g. foo.items for Foo.has_many :items
# File activerecord/lib/active_record/associations/collection_association.rb, line 29
def reader(force_reload = false)
if force_reload
ActiveSupport::Deprecation.warn( Passing an argument to force an association to reload is now deprecated and will be removed in Rails 5.1. Please call `reload` on the result collection proxy instead..squish)
klass.uncached { reload }
elsif stale_target?
reload
end
if null_scope?
# Cache the proxy separately before the owner has an id
# or else a post-save proxy will still lack the id
@null_proxy ||= CollectionProxy.create(klass, self)
else
@proxy ||= CollectionProxy.create(klass, self)
end
end Related methods
- Instance methods
- add_to_target
- any?
- build
- concat
- count
- create
- create!
- delete
- delete_all
- destroy
- destroy_all
- distinct
- empty?
- fifth
- find
- first
- forty_two
- fourth
- ids_reader
- ids_writer
- include?
- last
- length
- load_target
- many?
- null_scope?
- reader
- replace
- replace_on_target
- reset
- scope
- second
- second_to_last
- select
- size
- take
- third
- third_to_last
- transaction
- uniq
- writer
- Private methods
-
_create_record -
callback -
callbacks_for -
concat_records -
create_scope -
delete_or_destroy -
delete_records -
fetch_first_nth_or_last_using_find? -
find_by_scan -
find_target -
first_nth_or_last -
get_records -
include_in_memory? -
insert_record -
merge_target_lists -
remove_records -
replace_common_records_in_memory -
replace_records