MethodBox:Installation

Installing Ruby and dependencies
You will need:
 * Ruby 1.8.7
 * Mac OSX comes with 1.8.7 pre-installed (you may have to install the developer tools which came with your machine). On Ubuntu you can install with
 * Ruby gems
 * See here for installation instructions. Mac OSX comes with gem installed, you may want to update it with.
 * Bundler
 * Bundler is used to manage dependencies. Install through ruby gems with
 * Some gems depend on C binaries, you will probably need to install Image Magick, libxml2 and libxslt. On Ubuntu Linux these can be installed by .  On Mac OSX we recommend using Mac Ports and trying  . The XML libraries are probably already installed on Mac OS X, but if they are not you can also install them with Mac Ports:.
 * In addition the database backend adapters also rely on having the corresponding packages installed prior to running bundle. The packages to install are  and   on Ubuntu.

Download and setup
The code is hosted on github and uses git as its version management tool. Git can be installed with  on Ubuntu or   on Mac OS X.

To download the MethodBox code try.

There are several config files which you need to edit:
 * config/environment_local.example.rb
 * contains various constants which are used eg. to point the delayed job tasks to the correct folder for data storage. Copy file to environment_local.rb and then make the changes.  Note: There are a few redundant constants in this file and we are in the process of removing them.
 * there is a constant called  which can be set to 'http' or 'https' and is used by the config/routes.rb file to send all routes over 'https' if you require
 * For a complete list of constants see here
 * config/environment.example.rb
 * includes set up for the exception handler (using the ExceptionNotification plugin) and needs your email address so it can send any bug reports to the correct address. Copy file to environment.rb and then make the appropriate changes.
 * config/environments/production.example.rb & development.example.rb
 * These are files for environment specific details. If you want to run the server in a particular environment eg. production then you need production.rb etc.  The file needs email details that MethodBox uses to send out notifications, see below for details.  It also has a   which is an obfuscated url that you define and can give to someone interested in the internal download stats. Copy file to eg. development.rb etc and then make the changes.
 * config/database.example.yml
 * Change to reflect the database names, user & passwords and also the database adapter. Save the changes as config/database.yml
 * vendor/plugins/acts_as_solr/config/solr_environment.example.rb
 * needs SOLR_DATA_PATH changed to point to where SOLR should store its data and is saved as solr_environment.rb

Bundler
MethodBox uses bundler to handle its gems. to install it and then  in the MethodBox root to install the gems in the application. The gems used by MethodBox are listed in the file called Gemfile in the application root.

Migrations
From the rails root try. Note that by default this will run the migrations for the development database. If you want to run them for another environment eg. production then try. You can also load the schema.rb file (a dump of the entire database schema) through. However, there is always the chance that someone has forgotten to commit the latest version of it so it could be out of date. You will also need to set up the savage beast forums tables if setting up the database using migrations by running.

If you encounter the 'undefined local variable or method 'version_requirements' for #' error see the comment and solution in the  file.

SSL & https
Set the  in   to 'https'. Also change the  to true. All routes will then be sent over https. The SSL Requirement plugin is used to ensure that if you request a route over http and it should be https then it gets redirected. It is too difficult in rails 2 to routes some urls over http and others over https so we don't try. You will also need certificates for your web server. Testing the https routes is 'hard' in development mode and you will have to run the  script as well as the. If running https in development mode you will need to generate public/private ssl certificates, name them server.key and server.crt and copy to config/certs.

MethodBox and RVM
If you are using Ruby Version Manager (RVM) then it will pick up the details from the .rvmrc file in the methodbox root and try to create a gemset. You may have to install ruby-1.8.7 for RVM to use, try. It may also fail to install bundler and you may have to install it manually using  (no need for sudo when using rvm, everything is installed under your account). We have used RVM successfully on OSX and Ubuntu and also while deploying on Passenger in Apache

SOLR setup
Apache SOLR is used to index fields from various models so that they can be quickly searched. It comes packaged within MethodBox but does require a Java Runtime Environment (JRE) to run. Mac OS X will generally have this already installed but you might need to install it yourself under Linux.

Set  to true in the appropriate environment file. vendor/plugins/acts_as_solr/solr_environment.example.rb needs  changed to point to where SOLR should store its data and is saved as solr_environment.rb. Don't forget to run the SOLR server with  and stop with. SOLR sometimes complains when starting that certain directories or pid files are missing, just create the directories as necessary. Note that when SOLR bails out this way then you cannot stop with  but it will still have used port 8983 (port 8984 in production). Use  or similar to find the process number and kill it off. In production mode don't forget to start it using rake

Delayed job setup
Data/Metadata uploads and Data Extract creation are processed in the background using the delayed job plugin. Change the constants in the environment_local.rb file as noted in setup above and run the command appropriate to the environment to start the delayed job worker running. In development this is. In production it is  since it runs as a background daemon. In production the idea is to have many delayed job workers running so that they can pick off new tasks as they come in and start processing immediately. Start as many of them as memory allows. To stop the workers in production mode use, this will stop all the workers that are currently running.

Before starting any workers in production mode you must create a directory for their temporary data to go:

Email & user registration setup
You need to set EMAIL_ENABLED=true in environment_local.rb and also set ACTIVATION_REQUIRED=true in the appropriate file in /environments. If you want new users to join then set REGISTRATION_CLOSED=false in environment_local, otherwise you will have to approve users through the admin interface. You then need to add the ActivationMailer config to the environment file eg

This setup is for TLS/SSL using gmail, it's a lot easier with non-authenticated SMTP.

User login & authentication
MethodBox uses the restful authentication plugin. It is also set up to use the Shibboleth/UK Federation authorisation service with your UK University login id or similar.

Running MethodBox
When developing and testing MethodBox run the standard Rails server:.

If you are planning on running a production MethodBox server we recommend using Phusion Passenger for the Apache HTTP Server.