I am trying to create a custom method called full_address that takes the values of the address, city, state, and zip columns together.
Here is what my rails model location.rb looks like.
class Location < ActiveRecord::Base
attr_accessible :address, :city, :state, :zip, :latitude, :longitude
def full_address
[address, city, state, zip].compact.join(', ')
end
geocoded_by :full_address
after_validation :geocode
end
Does that work? If so, how?
Thanks in advance.
Yes it works, adress, city, state and zip are methods generated to access the instance variable value. Here is an example to explain