Skip to content

Instantly share code, notes, and snippets.

@jabbett
Last active April 12, 2019 03:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jabbett/07522fd44859e614de32f3863a1b6b8d to your computer and use it in GitHub Desktop.
Save jabbett/07522fd44859e614de32f3863a1b6b8d to your computer and use it in GitHub Desktop.
Setting up Ahoy models to use a separate datastore
module Ahoy
class AhoyBase < ActiveRecord::Base
establish_connection DB_STATS
self.abstract_class = true
end
end
module Ahoy
class Event < AhoyBase
include Ahoy::Properties
self.table_name = "ahoy_events"
belongs_to :visit
belongs_to :user, optional: true
end
end
class Visit < Ahoy::AhoyBase
has_many :ahoy_events, class_name: "Ahoy::Event"
belongs_to :user, optional: true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment