Skip to content

Building from Scratch

Mark Bussey edited this page Jan 25, 2019 · 11 revisions

This guide walks you through the steps to set up a template-generated instance of Hyrax which can be used with the other tutorials in this Wiki. We have followed the main outline of the instructions in the Hyrax README, and we have added the steps to make using a docker-based environment easier.

Goals:

  • Set up a Hyrax-based Rails application
  • Be able to log into a local Hyrax instance and submit a work

Prerequisites

Steps

  1. Your container should be running and you should be at a prompt that looks like

    root@0bb51af4e22d:/californica#
    
  2. Generate a Hyrax application using the basic application template

    rails _5.1.6_ new hyrax_demo -m https://raw.githubusercontent.com/samvera/hyrax/v2.3.3/template.rb --no-spring

    NOTE: using the template file above to set up your application is equivalent to running the following individual commands

    1. Run rails _5.1.6_ new hyrax_demo --no-spring
    2. cd hyrax_demo
    3. Add gem 'hyrax', '2.3.3' to your Gemfile
    4. bundle install
    5. rails generate hyrax:install -f
    6. rails db:migrate
  3. Change directory to the root of the newly generated application

    cd hyrax_demo
  4. For the tutorials, set background jobs to run inline by editing config/application.rb around line 11

    # after the line
    #   class Application < Rails::Application
    
        config.active_job.queue_adapter = :inline
  5. Configure the application to use the SOLR container by editing config/solr.yml and updating the ports to match the ones in ./docker-compose.yml

  6. Make the same changes to config/blacklight.yml by updating the ports to match the ones in ./docker-compose.yml

  7. Configure the application to use the Fedora container by editing config/Fedora.yml and updating the ports to match the ones in ./docker-compose.yml

  8. Generate the default admin set:

    bundle exec rails hyrax:default_admin_set:create
  9. Create a work type to be used in future tutorials. To generate a new work type, we follow the instructions in the Hyrax README. In this case, our work type will be Image.

    bundle exec rails generate hyrax:work Image

    Restart Rails after generating a new work type, if Rails was running already.

  10. Open a browser window and go to http://localhost:3000. You should be able to create an account and log in. Once you have logged in, go to http://localhost:3000/concern/images/new. You should be able to submit a new Work object.

Sample Code

To see the sample application at this stage, go to https://github.com/RepoCamp/berlin2018/tree/walkthrough