鉴于以下模型:
商业
class BusinessUser < ActiveRecord::Base
belongs_to :business, polymorphic: true
belongs_to :user
enum role: {:owner => 0, :employee => 1, :admin => 2}
validates_presence_of :user
validates :user, uniqueness: { scope: :business, message: "Each user can only have one role" }
end
BusinessUser
class User < ActiveRecord::Base
has_many :business_users
has_many :businesses, through: :business_users, source_type: Business, source: :business
end
用户
02-14 03:39:29.569 30081 30096 E RecognitionService: call for recognition service without RECORD_AUDIO permissions
如何确保每个企业至少有一个具有角色的business_user:owner?