<%= autogenerated_model_warning %> class Role < ApplicationRecord validates :canvas_role_id, uniqueness: true, presence: true def self.create_or_update(role_params) role = Role.find_or_initialize_by(canvas_role_id: role_params['id']) role.assign_attributes(label: role_params['label'], base_role_type: role_params['base_role_type'], account: role_params['account'], permissions: role_params['permissions'], workflow_state: role_params['workflow_state']) role.save! if role.changed? role end end