BETYdb 5.0
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:
-
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 getfatal: no tag exactly matches 'c7f98a8ab58acf0b2f68fde825f60b0dce236ab8'`.
To fix this problem, run
git fetch
and then re-rungit describe --tags --exact-match
. If you are not on the correct version, upgrade to BETYdb 4.21
before doing this upgrade. -
Run
git pull
to get the latest version of the master branch. -
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
dorvm 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 atvendor/bundle
. In this
case, the RVM Gem set does not much matter. You can check ifbundle
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.
-
Run the bundler to get all the needed Gems stored in the right place:
bundle
-
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 thebundle
command. To build the Apache module, runbundle exec passenger-install-apache2-module
Choose Ruby as the language to build for. After the build is complete, the
script will print out updatedLoadModule
,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. -
Whether or not you are using RVM, you may need to update the version of Ruby
specified in your Apache configuration file. Runpassenger-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 prependbundle exec
to the foregoing command.)Edit the configuration file as needed.
(If your existing configuration files do not override the
PassengerDefaultRuby
directive with aPassengerRuby
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 thepassenger-config
command should match the path in the
PassengerDefaultRuby
directive.) -
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 formSetEnv SECRET_KEY_BASE <secret key>
where
<secret key>
is the value you generated. This should go in the block
of theDirectory
directive corresponding to the path where your BETYdb Rails
code is located. -
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
withapt-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 theRAILS_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 theRAILS_RELATIVE_URL_ROOT
setting:bundle exec rake assets:precompile RAILS_ENV=production
-
Restart the Apache httpd server to enable the updated configuration.
-
Test your site to make sure it is working.