Skip to content

Instantly share code, notes, and snippets.

@booherbg
Last active August 29, 2015 14:26
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 booherbg/327e43b1502e66fdbb45 to your computer and use it in GitHub Desktop.
Save booherbg/327e43b1502e66fdbb45 to your computer and use it in GitHub Desktop.
Adding apartment to our api project
  1. add apartment to gemfile
  2. run initializer to generate config/apartment.rb
  3. Create our Event model (which maps to schemas)
  4. before_validate: create self.schema that uses .parameterize.underscore from self.name on event model
  5. after_create: create new apartment tenant on the event model
  6. Set up the config to ignore a few of our models that are public
  7. hard code the config to select a single event schema, for now
  8. migrate over all the data:
scans = Scan.all
Apartment::Tenant.switch!('old-event')
scans.each{ |s| Scan.create(s.attributes) }

that was it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment