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.
cryptogopher 1b7f2f0abd Added test_defaults_seed_and_load_into_empty_project
Added :defaults scopes to models
Added :sources and :formulas fixtures
Loading defaults from seeds.rb using rake task instead of migration
2020-08-29 01:26:36 +02:00

14 lines
351 B
Ruby

class Source < ActiveRecord::Base
belongs_to :project, required: false
scope :defaults, -> { where(project: nil) }
validates :name, 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