Added :defaults scopes to models Added :sources and :formulas fixtures Loading defaults from seeds.rb using rake task instead of migration
14 lines
354 B
Ruby
14 lines
354 B
Ruby
class Unit < ActiveRecord::Base
|
|
belongs_to :project, required: false
|
|
|
|
scope :defaults, -> { where(project: nil) }
|
|
|
|
validates :shortname, presence: true, uniqueness: {scope: :project_id}
|
|
|
|
# Has to go before any 'dependent:' association
|
|
before_destroy do
|
|
# FIXME: disallow destruction if any object depends on this quantity
|
|
nil
|
|
end
|
|
end
|