To learn how to setup application level encryption visit the below links.
You’re now ready to install ActiveStash.
- Add ActiveStash to your
- Install the new dependencies:
$ bundle install
- Create a CipherStash account (which will provision you a workspace) and then login:
$ rake active_stash:login[YOURWORKSPACEID]
Note: If you are using
zshyou may need to escape the brackets:
$ rake active_stash:login\['WorkspaceId'\]
Any model you use with
ActiveStash::Searchneeds to have a
stash_idcolumn is used to link search results back to encrypted database records.
For example, to add a
stash_idcolumn to the database table for the
Usermodel, add the below migration:
$ rails g migration AddStashIdToUser stash_id:string:index $ rails db:migrate
- Add the
ActiveStash::Searchmixin to your user model, and declare what fields are searchable:
# app/models/user.rb class User < ApplicationRecord include ActiveStash::Search # Previously added application-level encryption, by either ActiveRecord Encryption or Lockbox encrypts :name, :email encrypts :dob, type: :date # Fields that will be indexed into CipherStash stash_index :name, :email, :dob end
- Reindex your existing encrypted database records into CipherStash:
$ rails active_stash:reindexall
If you want to just reindex one model, for example User, run:
$ rails active_stash:reindex[User]
You can also reindex in code:
Depending on how much data you have, reindexing may take a while but you only need to do it once.
ActiveStash will automatically index (and delete) data as it records are created, updated and deleted.
For more information visit the ActiveStash Ruby docs.