X-Git-Url: https://projects.mako.cc/source/selectricity-live/blobdiff_plain/ad5ca8bbfbef358919aa877e78dceb27fdc6387a..823d530ba46c1fb3518c4deef0081738503837eb:/app/models/election.rb diff --git a/app/models/election.rb b/app/models/election.rb index 59a10bf..7343d72 100644 --- a/app/models/election.rb +++ b/app/models/election.rb @@ -15,6 +15,12 @@ class Election < ActiveRecord::Base require 'date' + def initialize(params={}) + super + self.enddate = read_attribute( :enddate ) || \ + Time.now + 14.days - 1.second + end + def other_methods if election_method @other_methods = ELECTION_TYPES.reject {|i| i == election_method} @@ -27,11 +33,6 @@ class Election < ActiveRecord::Base def startdate read_attribute( :startdate ) || Time.now end - - def enddate - date = read_attribute( :enddate ) || Time.now + 14 - date - 1.second - end def enddate=(date) date += 1.day