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
12 lines
510 B
Ruby
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
|