Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Matt-Bishop's Profile

GitHub User: Matt-Bishop

Comments by

Avatar

whoops, had those geocoded_by calls reversed

Avatar

Is it possible to make the method of geocoding conditional? i want to geocode by ip_address by default but if the user updates there current address, I want to then geocode by that.Anyone have ideas on how to do that? something like

ruby
class Patron < ActiveRecord::Base
  attr_accessible :ip_address, :address, :latitude, :longitude
  
  unless self.address.nil?
    geocoded_by :ip_address
  else
    geocoded_by :address
  end  
  
  after_validation :geocode 
end
Avatar

For anyone who is still using ruby 1.8.7 for rails 3.0.5
SecureRandom.urlsafe_base64 will generate a method not found error. I used SecureRandom.hex as a substitute and it worked. Just thought I'd share in case this helps anyone...