mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-03-21 12:29:03 +01:00
models linking
This commit is contained in:
parent
f0c5b0eb09
commit
0a5e373730
@ -8,13 +8,16 @@ class StatisticProfile < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :group
|
||||
|
||||
# relations to reservations, trainings, subscriptions
|
||||
has_many :subscriptions, dependent: :destroy
|
||||
accepts_nested_attributes_for :subscriptions, allow_destroy: false
|
||||
|
||||
has_many :reservations, dependent: :destroy
|
||||
accepts_nested_attributes_for :reservations, allow_destroy: false
|
||||
|
||||
# Trainings that were validated by an admin
|
||||
has_many :statistic_profile_trainings, dependent: :destroy
|
||||
has_many :trainings, through: :statistic_profile_trainings
|
||||
|
||||
def str_gender
|
||||
gender ? 'male' : 'female'
|
||||
end
|
||||
|
@ -12,9 +12,9 @@ class Training < ActiveRecord::Base
|
||||
|
||||
has_many :reservations, as: :reservable, dependent: :destroy
|
||||
|
||||
# members who DID the training
|
||||
has_many :user_trainings, dependent: :destroy
|
||||
has_many :users, through: :user_trainings
|
||||
# members who has validated the trainings
|
||||
has_many :statistic_profile_trainings, dependent: :destroy
|
||||
has_many :statistic_profiles, through: :statistic_profile_trainings
|
||||
|
||||
has_many :trainings_pricings, dependent: :destroy
|
||||
|
||||
|
@ -31,10 +31,6 @@ class User < ActiveRecord::Base
|
||||
has_many :project_users, dependent: :destroy
|
||||
has_many :projects, through: :project_users
|
||||
|
||||
# Trainings that were already passed
|
||||
has_many :user_trainings, dependent: :destroy
|
||||
has_many :trainings, through: :user_trainings
|
||||
|
||||
belongs_to :group
|
||||
|
||||
has_many :users_credits, dependent: :destroy
|
||||
|
Loading…
x
Reference in New Issue
Block a user