app/models/app.rb
# Copy app attributes from another app.
Copy app attributes from another app.
Copy app attributes from another app .
def copy_attributes_from(app_id)
    copy_app = App.where(_id: app_id).first
    return if copy_app.blank?
    (copy_app.fields.keys - %w(_id name created_at updated_at)).each do |k|
      send("#{k}=", copy_app.send(k))
    end
    %w(watchers issue_tracker notification_service).each do |relation|
      if (obj = copy_app.send(relation))
        send("#{relation}=", obj.is_a?(Array) ? obj.map(&:clone) : obj.clone)
      end
    end
  end
def copy_attributes_from ( app_id ) copy_app = App . where ( _id : app_id ) . first return if copy_app . blank? ( copy_app . fields . keys - %w( _id name created_at updated_at ) ) . each do | k | send ( "#{k}=" , copy_app . send ( k ) ) end %w( watchers issue_tracker notification_service ) . each do | relation | if ( obj = copy_app . send ( relation ) ) send ( "#{relation}=" , obj . is_a? ( Array ) ? obj . map ( & :clone ) : obj . clone ) end end end
Copy app attributes from another app.
Copy app attributes from another app .
# Copy fields # Clone the embedded objects that can be changed via apps/edit (ignore errs, etc.)
app_id
<not_specific>