Files
openfoodnetwork/app/models/enterprise_role.rb
Luis Ramos e52937c113 Use rubocop auto correct to add frozen string literal to all files
This is an unsafe auto corection, we will need to trust our build here
2021-06-17 23:07:26 +01:00

13 lines
403 B
Ruby

# frozen_string_literal: true
class EnterpriseRole < ApplicationRecord
belongs_to :user, class_name: Spree.user_class.to_s
belongs_to :enterprise
validates :user, :enterprise, presence: true
validates :enterprise_id,
uniqueness: { scope: :user_id, message: I18n.t(:enterprise_role_uniqueness_error) }
scope :by_user_email, -> { joins(:user).order('spree_users.email ASC') }
end