method
find_target
Ruby on Rails latest stable (v7.1.3.2)
-
0 notes -
Class: ActiveRecord::Associations::BelongsToAssociation
find_target()
private
Hide source
# File activerecord/lib/active_record/associations/belongs_to_association.rb, line 46 def find_target find_method = if @reflection.options[:primary_key] "find_by_#{@reflection.options[:primary_key]}" else "find" end options = @reflection.options.dup (options.keys - [:select, :include, :readonly]).each do |key| options.delete key end options[:conditions] = conditions the_target = @reflection.klass.send(find_method, @owner[@reflection.primary_key_name], options ) if @owner[@reflection.primary_key_name] set_inverse_instance(the_target, @owner) the_target end