2020-03-30 11:33:12 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# UserCredit is the relation table between a Credit and an User.
|
|
|
|
# It saves the consumed credits only
|
2020-03-25 10:16:47 +01:00
|
|
|
class UsersCredit < ApplicationRecord
|
2016-03-23 18:39:41 +01:00
|
|
|
belongs_to :user
|
|
|
|
belongs_to :credit
|
|
|
|
|
2020-03-30 11:33:12 +02:00
|
|
|
belongs_to :training_credit, -> { where('credits.creditable_type = ?', 'Training') }, foreign_key: 'credit_id', class_name: 'Credit'
|
|
|
|
belongs_to :machine_credit, -> { where('credits.creditable_type = ?', 'Machine') }, foreign_key: 'credit_id', class_name: 'Credit'
|
2020-09-29 12:01:10 +02:00
|
|
|
belongs_to :space_credit, -> { where('credits.creditable_type = ?', 'Space') }, foreign_key: 'credit_id', class_name: 'Credit'
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|