lib/active_scaffold/attribute_params.rb
# Attempts to create or find an instance of the klass of the association in parent_column from the
# request parameters given. If params[primary_key] exists it will attempt to find an existing object
# otherwise it will build a new one.
Attempts to create or find an instance of the klass of the association in parent_column from the
request parameters given. If params[primary_key] exists it will attempt to find an existing object
otherwise it will build a new one.
Attempts to create or find an instance of the klass of the association in parent_column from the request parameters given . If params [ primary_key ] exists it will attempt to find an existing object otherwise it will build a new one .
def find_or_create_for_params(params, parent_column, parent_record)
      current = parent_record.send(parent_column.name)
      klass = parent_column.association.klass(parent_record)
      if params.key? klass.primary_key
        record_from_current_or_find(klass, params[klass.primary_key], current)
      elsif klass.authorized_for?(:crud_type => :create)
        association = parent_column.association
        record = klass.new
        if association.reverse_association&.belongs_to? && (association.collection? || current.nil?)
          record.send("#{parent_column.association.reverse}=", parent_record)
        end
        record
      end
    end
def find_or_create_for_params ( params , parent_column , parent_record ) current = parent_record . send ( parent_column . name ) klass = parent_column . association . klass ( parent_record ) if params . key? klass . primary_key record_from_current_or_find ( klass , params [ klass . primary_key ] , current ) elsif klass . authorized_for? ( :crud_type => :create ) association = parent_column . association record = klass . new if association . reverse_association &. belongs_to? && ( association . collection? || current . nil? ) record . send ( "#{parent_column.association.reverse}=" , parent_record ) end record end end
Attempts to create or find an instance of the klass of the association in parent_column from the
request parameters given.
Attempts to create or find an instance of the klass of the association in parent_column from the request parameters given .
params
<not_specific>
parent_column
<not_specific>
parent_record
<not_specific>