Skip to content

Instantly share code, notes, and snippets.

@cwsaylor
Last active August 29, 2015 14:07
Show Gist options
  • Save cwsaylor/66e19041f6ecaded73bf to your computer and use it in GitHub Desktop.
Save cwsaylor/66e19041f6ecaded73bf to your computer and use it in GitHub Desktop.
# USAGE:
# gem install rails
# gem install attr_encrypted
# edit mysql connection parameters
# edit attr_encrypted line and update PUT KEY HERE
require "rubygems"
require "active_record"
require "attr_encrypted"
ActiveRecord::Base.establish_connection(
:adapter => "mysql2",
# :host => "db01a.prod.doximity.com",
:host => "127.0.0.1",
:database => "doximity_dev",
:username => "root",
:password => ""
)
module Inbox
class Notification < ActiveRecord::Base
self.table_name = "inbox_notifications"
attr_encrypted :subject, :body, key: "PUT KEY HERE"
end
class RecruiterMessage < Notification
end
class ExpertFinderMessage < Notification
end
class Message < Notification
end
end
m = Inbox::Notification.find(ARGV[0])
puts JSON.generate({ subject: m.subject, body: m.body })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment