Skip to content

Developer Notes

Alicia Cozine edited this page Mar 31, 2016 · 18 revisions

How to create a monograph with attached sections using the rails console

# Decide what visibility you want the monograph to have
vis = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC

# Decide which press the monograph will belong to
press = Press.where(subdomain: 'umich').first

# A monograph is required to have a title and a press.
# Because the monograph is stored in fedora, but the press is stored
# in the relational database, we use the press subdomain as the key
# instead of the id.
monograph = Monograph.new(title: ['Monograph #1'], press: press.subdomain, visibility: vis)

# The person who created the monograph must have edit access to the monograph
monograph.apply_depositor_metadata('admin@example.com')

monograph.save!

chapter1 = Section.new(title: ['Chapter 1'], visibility: vis)
chapter1.apply_depositor_metadata('admin@example.com')
chapter1.save!

# Add the section to the monograph
monograph.ordered_members << chapter1
monograph.save!

How to re-index Solr using the rails console

If you re-start solr, you'll need to reindex all your fedora objects. Otherwise, none of your monographs or files will be visible in the UI.

Note: In order to get all the objects correctly indexed, including all their associations, you need to reindex twice.

ActiveFedora::Base.reindex_everything

Then again

ActiveFedora::Base.reindex_everything

How to clean all the objects out of your fedora

Not recommended for production environments, but useful for dev or test environments, when you want to start with a clean slate. This will delete everything in fedora.

In the rails console:

require 'active_fedora/cleaner'
ActiveFedora::Cleaner.clean!

Deploy application to DCE or UM Environments with Capistrano

Capistrano Overview

With Capistrano, the code is deployed to /opt/heliotrope (or another directory as defined by the :deploy_to setting). Within that directory the file revisions.log shows the GitHub commit version and the deployer. The working code is defined by the symlink current, which points to a timestamped subdirectory of the releases directory. Config files containing passwords, log files, and other files and directories that should not update with every code change are stored in the shared directory and defined as :linked_files and :linked_dirs - default Capistrano settings are in heliotrope/config/deploy.rb; these can be overridden per environment in the config/deploy/<env-name>.rb files.

Deploy to DCE

You will first need to have your ssh keys associated with the deploy user on the DCE sandbox. Before deploying, also ensure you are using a current version of Ruby and the project's gemset. From the project/heliotrope root on your local machine, do:

bundle exec cap aws deploy

To rollback a deployment, do:

bundle exec cap <env-name> deploy:rollback

Deploy to UM

From the project/heliotrope root, do:

bundle exec cap <env-name> deploy