diff --git a/app/models/statistic_profile.rb b/app/models/statistic_profile.rb index acc6cd495..5ee6c93ae 100644 --- a/app/models/statistic_profile.rb +++ b/app/models/statistic_profile.rb @@ -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 diff --git a/app/models/training.rb b/app/models/training.rb index c7ae28f5e..682204239 100644 --- a/app/models/training.rb +++ b/app/models/training.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 2b4c0b808..343673b5c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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