Skip to content

Instantly share code, notes, and snippets.

@miketierney
Created March 16, 2009 14:05
Show Gist options
  • Save miketierney/79892 to your computer and use it in GitHub Desktop.
Save miketierney/79892 to your computer and use it in GitHub Desktop.
class Event < ActiveRecord::Base
belongs_to :group
belongs_to :location
validates_presence_of :group_id, :location_id, :start_time, :end_time
define_index do
indexes name
end
end
class Group < ActiveRecord::Base
has_many :events
has_many :locations, :through => :events
validates_presence_of :name
define_index do
indexes name
indexes events.description, :as => :event_descriptions
indexes [locations.name, locations.address], :as => :location_addresses
end
end
class Location < ActiveRecord::Base
acts_as_mappable :auto_geocode => true, :lat_column_name => 'latitude', :lng_column_name => 'longitude'
has_many :events
has_many :groups, :through => :events
validates_presence_of :name, :address
define_index do
indexes name, :sortable => true
indexes address, :sortable => true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment