lib/active_scaffold/attribute_params.rb
# Attempts to find an instance of klass (which must be an ActiveRecord object) with id primary key
# Returns record from current if it's included or find from DB
Attempts to find an instance of klass (which must be an ActiveRecord object) with id primary key
Returns record from current if it's included or find from DB
Attempts to find an instance of klass ( which must be an ActiveRecord object ) with id primary key Returns record from current if it ' s included or find from DB
def record_from_current_or_find(klass, id, current)
      if current.is_a?(ActiveRecord::Base) && current.id.to_s == id
        current
      elsif current.respond_to?(:any?) && current.any? { |o| o.id.to_s == id }
        current.detect { |o| o.id.to_s == id }
      else 
        klass.find(id)
      end
    end
def record_from_current_or_find ( klass , id , current ) if current . is_a? ( ActiveRecord :: Base ) && current . id . to_s == id current elsif current . respond_to? ( :any? ) && current . any? { | o | o . id . to_s == id } current . detect { | o | o . id . to_s == id } else klass . find ( id ) end end
Attempts to find an instance of klass (which must be an ActiveRecord object) with id primary key
Returns record from current if it's included or find from DB
Attempts to find an instance of klass ( which must be an ActiveRecord object ) with id primary key Returns record from current if it ' s included or find from DB
# modifying the current object of a singular association # modifying one of the current objects in a plural association # attaching an existing but not-current object
klass
<not_specific>
id
<not_specific>
current
<not_specific>