forked from fixin.me/fixin.me
@@ -3,7 +3,8 @@ class Unit < ApplicationRecord
|
||||
|
||||
belongs_to :user, optional: true
|
||||
belongs_to :base, optional: true, class_name: "Unit"
|
||||
has_many :subunits, class_name: "Unit", inverse_of: :base, dependent: :restrict_with_error
|
||||
has_many :subunits, class_name: "Unit", inverse_of: :base,
|
||||
dependent: :restrict_with_error
|
||||
|
||||
validate if: ->{ base.present? } do
|
||||
errors.add(:base, :user_mismatch) unless user_id == base.user_id
|
||||
|
||||
@@ -12,10 +12,10 @@ class User < ApplicationRecord
|
||||
disabled: 0, # administratively disallowed to sign in
|
||||
}, default: :active, validate: true
|
||||
|
||||
has_many :readouts, dependent: :destroy
|
||||
has_many :readouts, dependent: :delete_all
|
||||
accepts_nested_attributes_for :readouts
|
||||
has_many :quantities, dependent: :destroy
|
||||
has_many :units, dependent: :destroy
|
||||
has_many :quantities, dependent: :delete_all
|
||||
has_many :units, dependent: :delete_all
|
||||
|
||||
validates :email, presence: true, uniqueness: true,
|
||||
length: {maximum: type_for_attribute(:email).limit}
|
||||
|
||||
Reference in New Issue
Block a user