Skip to content

BETYdb 5.0

Compare
Choose a tag to compare
@gsrohde gsrohde released this 07 Aug 21:02
· 259 commits to master since this release
a0aa89c

Upgrade to Rails 5

Summary of Changes

This release includes a major Rails upgrade—from version 4 to version 5—as well
as a few bug fixes.

Bug fixes

  • Add experiments table to data menu in the BETYdb Rails app #488

    Up until now, the only way to visit the experiments table was to type the
    correct URL into the browser address box. This fix adds a link in the Data
    menu.

  • Can't create or edit Experiments via the BETYdb Web app #581

    The Rails 4 upgrade introduced a bug preventing users from creating or editing
    experiments via the BETYdb Web app. This problem is fixed by this release.

  • Getting ForbiddenAttributesError during search on TERRA-REF instance #582

    Certain searchs via the version 1 API failed with a ForbiddenAttributesError.
    This has been fixed.

Steps Needed for Upgrade

Note: This release is a major upgrade, so a few more steps than usual are
required. There are, however, no database migrations in the release, so users
may upgrade at their leisure and still be able to do data synchronizations.

To begin with, be sure the current directory is the Rails root directory and
that you are logged in as the BETYdb app user (the user that owns the files
under the Rails root directory, and the user that the BETYdb Rails app runs as).
Then do the following:

  1. Check that you are currently on the 4.21 release. You can do this by running

    git describe --tags --exact-match
    

    It should return betydb_4.21. It's possible that you are on the correct version but somehow didn't pull
    down the tag name. In that case, you should get

    fatal: no tag exactly matches 'c7f98a8ab58acf0b2f68fde825f60b0dce236ab8'`.
    

    To fix this problem, run git fetch and then re-run git describe --tags --exact-match. If you are not on the correct version, upgrade to BETYdb 4.21
    before doing this upgrade.

  2. Run git pull to get the latest version of the master branch.

  3. Upgrade Ruby, if needed.

    Rails 5 requires Ruby language version 2.2.2 or newer. If you already have
    Ruby 2.2.2 or later installed, skip to the next step. Otherwise, continue as
    follows:

    If you are using RVM:

    Ensure you are using the right version of Ruby and the right Gem set. Running

    rvm current

    should return ruby-2.3.0@betydb_rails5. If not, make sure you have ruby-2.3.0 installed:

    rvm list

    If it is not listed, run

    rvm install "ruby-2.3.0"

    Now make the Gem set "betydb_rails5":

    rvm gemset create "betydb_rails5"

    Run the following three commands to leave and return to the BETYdb Rails root
    directory and check the current version of Ruby and the the current gemset:

    cd ..
    cd -
    rvm current

    The last command should return "ruby-2.3.0@betydb_rails5", automatically
    creating the required Gem set if it does not exist. Alternatively, you can just
    do

    rvm use "ruby-2.3.0@betydb_rails5" --create

    Note: If you ran the bundler with the --deployment option, Gems will be
    stored under the BETYdb Rails root directory at vendor/bundle. In this
    case, the RVM Gem set does not much matter. You can check if bundle is
    using the --deployment option by running:

    bundle config path

    If you aren't using RVM:

    Make sure you have Ruby version 2.2.2 or later installed, and make sure it is
    the default version used:

    ruby --version

    should return version 2.2.2 or newer.

  4. Run the bundler to get all the needed Gems stored in the right place:

    bundle
  5. Upgrade Phusion Passenger

    It is strongly recommended you upgrade Phusion Passenger to version 5.3.4. If
    you currently run a version of Passenger downloaded through the bundler, you
    can continue to do so. The bundler will automatically download version 5.3.4
    when you run the bundle command. To build the Apache module, run

    bundle exec passenger-install-apache2-module

    Choose Ruby as the language to build for. After the build is complete, the
    script will print out updated LoadModule, IfModule, PassengerRoot, and
    PassengerDefaultRuby directives for using in your Apache configuration
    files. Edit your configuration files, replacing the existing
    Passenger-related directives with these.

    For more extensive Phusion Passenger installation instructions, consult
    https://www.phusionpassenger.com/library/walkthroughs/deploy/, especially if
    you are not planning to use the copy of Phusion Passenger found in the Gem set
    maintained by the bundler.

  6. Whether or not you are using RVM, you may need to update the version of Ruby
    specified in your Apache configuration file. Run

    passenger-config about ruby-command

    to find what value to use with the PassengerRuby directive in the Apache
    configuration file. (If you are using the copy of Passenger downloaded by the
    bundler, you may need to prepend bundle exec to the foregoing command.)

    Edit the configuration file as needed.

    (If your existing configuration files do not override the
    PassengerDefaultRuby directive with a PassengerRuby directive (inside a
    VirtualHost block, say), then you do not need to include this
    PassengerRuby directive. In this case, the path to the Ruby interpreter
    found using the passenger-config command should match the path in the
    PassengerDefaultRuby directive.)

  7. If you haven't already done so, set SECRET_KEY_BASE.

    This step should have been done in the upgrade to Rails 4. Here are the
    instructions if it remains to be done:

    Run

    bundle exec rake secret

    to generate a suitable value for this variable. The value must be in the
    environment of the application. One way to do this is to use a directive in
    an Apache configuration file of the form

    SetEnv SECRET_KEY_BASE <secret key>
    

    where <secret key> is the value you generated. This should go in the block
    of the Directory directive corresponding to the path where your BETYdb Rails
    code is located.

  8. Compile Rails Assets

    BETYdb now uses the Rails Assets Pipeline. You need to compile these
    assets, and to do so, you need a Javascript runtime. You may already have one
    on your server. If not, you can install one. On CentOS, for example, use
    this command:

    sudo yum install nodejs

    On Ubuntu, replace yum with apt-get.

    To compile the assets, first determine whether you serve your BETYdb site at a
    subURI. For example, if the URL of the BETYdb home page is something like
    https://www.mycollege.edu/bety, then /bety is the subURI and you should
    use the RAILS_RELATIVE_URL_ROOT variable with the compile task like this:

    bundle exec rake assets:precompile RAILS_ENV=production RAILS_RELATIVE_URL_ROOT=/bety

    On the other hand, if you serve BETYdb from the root URL of your site, at
    https://www.mycollege.edu, say, then omit the RAILS_RELATIVE_URL_ROOT
    setting:

    bundle exec rake assets:precompile RAILS_ENV=production
  9. Restart the Apache httpd server to enable the updated configuration.

  10. Test your site to make sure it is working.