adds Budget::Group model to group headings

many refactors through budget related models
This commit is contained in:
Juanjo Bazán
2016-06-09 18:00:06 +02:00
parent 3fae269c40
commit b5a6828e41
18 changed files with 156 additions and 110 deletions

View File

@@ -4,9 +4,11 @@ class Budget < ActiveRecord::Base
validates :phase, inclusion: { in: VALID_PHASES }
has_many :investments
has_many :ballots
has_many :headings
has_many :investments, dependent: :destroy
has_many :ballots, dependent: :destroy
has_many :groups, dependent: :destroy
has_many :headings, through: :groups
has_many :investments, through: :headings
def on_hold?
phase == "on_hold"
@@ -29,7 +31,6 @@ class Budget < ActiveRecord::Base
end
def heading_price(heading)
return price unless heading.present?
heading_ids.include?(heading.id) ? heading.price : -1
end
end