1
0
This repository has been archived on 2023-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
body_tracking/app/models/measurement_routine.rb
cryptogopher 18419f1aeb Added MeasurementRoutine as a nested Measurement model
Updated ItemsWithQuantities to work with MeasurementRoutine
Replaced ColumnViews HABTM with polymorphic HMT
Added Measurement notes
Added destroy restrictions on Quantity
Replaced BodyTrackingPluginController with Finders concern
Removed 'body_trackers' prefix from paths
Unified styling for textarea
2020-03-29 00:56:37 +01:00

12 lines
510 B
Ruby

class MeasurementRoutine < ActiveRecord::Base
belongs_to :project, required: true
has_many :measurements, -> { order "taken_at DESC" }, inverse_of: :routine,
foreign_key: 'routine_id', dependent: :restrict_with_error,
extend: BodyTracking::ItemsWithQuantities
has_many :columns, as: :column_view, dependent: :destroy,
extend: BodyTracking::TogglableColumns
has_many :quantities, -> { order "lft" }, through: :columns
validates :name, presence: true, uniqueness: {scope: :project_id}
end