花月(Kagetsu) CircleCI

kagetsu is a library for create or update method on ActiveRecord.

Requirement

  • Rails 5.2 or upper

Usage

User.create!(name: 'kotoko', email: '[email protected]')
user = User.create_or_update(key: { name: 'kotoko' }, update_attributes: { email: '[email protected]' })

user.email #=> [email protected]

Available Methods

  • ActiveRecord::Base#create_or_update
  • ActiveRecord::Base#create_or_update!