added method location= and revised location to handle missing fields better

This commit is contained in:
Jonathan Kolyer 2013-01-06 06:34:16 -06:00
parent 0425a9d389
commit d2ebfbde4f
1 changed files with 12 additions and 1 deletions

View File

@ -106,7 +106,18 @@ module JamRuby
end
def location
return "#{self.city}, #{self.state}, #{self.country}"
loc = self.city.blank? ? '' : self.city
loc = loc.blank? ? self.state : "#{loc}, #{self.state}" unless self.state.blank?
loc = loc.blank? ? self.country : "#{loc}, #{self.country}" unless self.country.blank?
loc
end
def location= location_hash
unless location_hash.blank?
self.city = location_hash[:city]
self.state = location_hash[:state]
self.country = location_hash[:country]
end if self.city.blank?
end
def should_validate_password?