Skip to content

Building from Scratch

Mark Bussey edited this page May 17, 2021 · 9 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 Vagrant-based virtual machine easier.

Goals:

  • Set up a Hyrax-based Rails application
  • Start Solr, Fedora, and Web servers
  • Be able to log into a local Hyrax instance and submit a work

Steps

  1. Generate a Hyrax application using the basic application template

    rails _5.1.7_ new ucla2019 -m https://raw.githubusercontent.com/samvera/hyrax/v3.0.0.pre.beta1/template.rb

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

    1. Run rails _5.1.7_ new ucla2019
    2. cd ucla2019
    3. Add gem 'hyrax', '3.0.0-beta1' to your Gemfile
    4. bundle install
    5. rails generate hyrax:install -f
    6. bundle install to install newly added dependencies from Hyrax
    7. rails db:migrate
    8. rails 'hyrax:default_collection_types:create'
  2. Change directory to the root of the newly generated application

    cd ucla2019
  3. 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
  4. Add the following lines to the top of ucla2019/.solr_wrapper:

    version: 7.7.1
    download_dir: /var/tmp

    This will point your solr config at the local Solr instance in /var/tmp.

  5. Point your fedora config at the local Fedora instance in /var/tmp by adding these lines to the end of ucla2019/.fcrepo_wrapper:

    version: 4.7.5
    download_dir: /var/tmp
  6. Generate the default admin set:

    bundle exec rails hyrax:default_collection_types:create
    bundle exec rails hyrax:default_admin_set:create
  7. 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.

  8. Add fits.log to your ucla2019/.gitignore file around line 19. This will be automatically generated once you begin uploading works to your repository.

  9. Start Redis, Solr, Fedora, and Web servers, each in a new terminal window. You'll want to leave these running in separate windows while you use your first terminal session for command-line exercises in the tutorials.

    In each new terminal session

    cd /ucla2019
    redis-server
    cd /ucla2019
    solr_wrapper  
    cd /ucla2019
    fcrepo_wrapper
  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 changes made during this lesson, go to ../compare/template_build...walkthrough Note: This also includes the changes added to be able to deploy using Docker.