Build and deploy a Ruby on Rails web application with IBM DB2 zOS
Arvind_Gupta 2700025SKH Visits (12865)
In this blog, we'll build a Bank as a sample application using IBM zOS database with Ruby on Rails. We'll walk you through the steps to create a Rails app, connect the app to the zOS database, then run the app. Building this simple Bank application demonstrates how easy it is to create and deploy a Rails app with ibm_db gem and zOS database.
Note - The below steps are applicable for DB2 LUW and DB2 iSeries database server as well.
DB2Connect license (For zOS and iSeries)
Familiarity with Ruby on Rails
Install Ruby on Rails and ibm_db gem
1. Install latest version of Ruby
Download and install ruby from here
2. Install latest version of Rails by running below command.
$gem install rails
3. Install IBM DB2 Ruby driver and Rails adapter by installing ibm_db gem with below command.
$gem install ibm_db
4. Copy DB2Connect license in <ibm_db gem installation dire
5. Verify Ruby driver installation with interactive Ruby shell, run below commands.
<database_name>", "", "" )
Change <hostname>, <port>, <user_id>, <password> and <database_name> accordingly in above command.
If you get output like below, that means connection was successful
Now close the connection by running below command
Deploy sample Rails application
1. Lets create a sample Rails application. We have already created a sample Bank application and code is published github, so you need not to spend time in creating application from scratch. Clone the code from github by running below command.
$Git clone http
2. Code details:
Database Tables :
Accounts and Users tables will created after migration is run successfully.
Views are present under glob
This application uses Save and Update rails adapter API.
3. Change directory to globalank
4. Edit the config/database.yml and specify zOS host, port, username, password, Schema, host, port, database details in below section and save it.
5. Run "bundle install" command to install required gems.
6. Now run below command to create tables in zOS database.
7. Run below command to start web server. By default it runs on localhost and 3000 as default port number.
To access remotely, you need to start with binding the machine IP address. You can also change default port number via below command.
$rails s --bi
8. To access bank application open browser and invoke
This will take you to login page. To explore Bank application, start with Signup and then create an account and perform deposit, Withdraw etc operations.