Skip to content

Instantly share code, notes, and snippets.

@jasdeepsingh
Created November 3, 2011 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasdeepsingh/1335379 to your computer and use it in GitHub Desktop.
Save jasdeepsingh/1335379 to your computer and use it in GitHub Desktop.
Store Model
class Store < ActiveRecord::Base
# Associations
belongs_to :user, :class_name => "User", :foreign_key => "merchant_id"
has_and_belongs_to_many :deals
# Validations
validates_presence_of :name, :street_address, :city, :postal_code, :province, :country_field
geocoded_by :address
after_validation :geocode
def address
[name, street_address, city, province, postal_code, country_field].compact.join(', ')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment