ddr-models
A Rails engine providing Hydra and ActiveRecord models and common services for the Duke Digital Repository.
Installation
Add to your application's Gemfile:
gem 'ddr-models'
and
bundle install
Configuration
ddr-models has several runtime dependencies that are independently configurable:
ddr-models configuration options:
- Authentication/Authorization options are set on Ddr::Auth.
Additional configuration steps
User model
Include Ddr::Auth::User
in app/models/user.rb
and remove content inserted by Hydra and Devise generators:
class User
include Ddr::Auth::User
#
# REMOVE:
# include Hydra::User
# devise :database_authenticatable [...]
#
# DO NOT REMOVE:
# Blacklight::User
end
Ability class
The hydra-head generator may have created a class module at app/models/ability.rb
like so:
class Ability
include Hydra::Ability
end
Change the class like so:
class Ability < Ddr::Auth::Ability
#
# REMOVE:
# include Hydra::Ability
#
# Add "ability definitions" -- i.e., subclasses of Ddr::Auth::AbilityDefinitions.
#
# self.ability_definitions += [ ... ]
#
end
Controller
Ddr::Auth::RoleBasedAccessControlsEnforcement
overrides current_ability
, gated_discovery_filters
and enforce_show_permissions
, so most likely it should be included in ApplicationController
.
class ApplicationController < ActionController::Base
include Ddr::Auth::RoleBasedAccessControlsEnforcement
end
SolrDocument model
Include Ddr::Models::SolrDocument
in app/models/solr_document.rb
class SolrDocument
include Blacklight::Solr::Document
include Ddr::Models::SolrDocument
...
end
Auxiliary Web Services
In order to use the auxiliary web services, set the DDR_AUX_API_URL
environment variable. You may wish to install the ddr-aux app locally and run it.
Migrations
Install the ddr-models migrations:
rake ddr_models:install:migrations
then
rake db:migrate db:test:prepare