forked from OpenNeo/impress
Matchu
4f564db785
Some important little upgrades but mostly straightforward! Note that there's still a known issue where item searches crash, I was hoping that this was a bug in Rails 4.2 that would be fixed on upgading to 5, but nope, oh well! Also uhh I just got a bit silly and didn't actually mean to go all the way to 5.2 in one go, I had meant to start at 5.0… but tbh the 5.1 and 5.2 changes seem small, and this seems to be working, so. Yeah ok let's roll!
20 lines
354 B
Ruby
20 lines
354 B
Ruby
class Campaign < ApplicationRecord
|
|
has_many :donations
|
|
|
|
def progress_percent
|
|
[(progress.to_f / goal) * 100, 100].min
|
|
end
|
|
|
|
def remaining
|
|
goal - progress
|
|
end
|
|
|
|
def complete?
|
|
progress >= goal
|
|
end
|
|
|
|
def self.current
|
|
self.where(active: true).first or
|
|
raise ActiveRecord::RecordNotFound.new("no current campaign")
|
|
end
|
|
end
|