Sha256: 7f4ab197fd3f3c36be10e63ff81662eb80abdfb2f1b0bf18d4ccfab9886db0e0

Contents?: true

Size: 508 Bytes

Versions: 8

Compression:

Stored size: 508 Bytes

Contents

class User < ActiveRecord::Base
  authenticates_with_sorcery!
  validates_presence_of :email
  has_many :group_users
  has_many :groups, through: :group_users
  has_many :role_group_users, through: :group_users
  accepts_nested_attributes_for :group_users, reject_if: :all_blank, allow_destroy: :true
  accepts_nested_attributes_for :role_group_users, reject_if: :all_blank, allow_destroy: :true
  
  scope :all_belonging_to, -> (user) { includes(group_users: :group).where(groups: { id: user.groups }) }
end

Version data entries

8 entries across 4 versions & 1 rubygems

Version Path
curupira-0.1.7 spec/dummy/app/models/user.rb
curupira-0.1.7 spec/tmp/app/models/user.rb
curupira-0.1.6 spec/dummy/app/models/user.rb
curupira-0.1.6 spec/tmp/app/models/user.rb
curupira-0.1.4 spec/dummy/app/models/user.rb
curupira-0.1.4 spec/tmp/app/models/user.rb
curupira-0.1.3 spec/dummy/app/models/user.rb
curupira-0.1.3 spec/tmp/app/models/user.rb