impress/app/models/campaign.rb
Matchu d97c32b5da Upgrade to Rails 5.2.8.1
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!
2023-10-23 19:05:05 -07:00

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