You can configure Ruby on Rails support in SAP Sybase IQ.
There are no prerequisites for this task.
gem install rails
gem install activerecord-sqlanywhere-adapter
Configure a database by creating a sqlanywhere.yml file in the Rails configs\databases directory. If you have installed Ruby in the \Ruby directory and you have installed version 3.1.3 of Rails, then the path to this file would be \Ruby\lib\ruby\gems\1.9.1\gems\railties-3.1.3\lib\rails\generators\rails\app\templates\config\databases. The contents of this file should be:
# # SQL Anywhere database configuration # # This configuration file defines the patten used for # database filenames. If your application is called "blog", # then the database names will be blog_development, # blog_test, blog_production. The specified username and # password should permit DBA access to the database. # development: adapter: sqlanywhere server: <%= app_name %> database: <%= app_name %>_development username: DBA password: sql # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: adapter: sqlanywhere server: <%= app_name %> database: <%= app_name %>_test username: DBA password: sql production: adapter: sqlanywhere server: <%= app_name %> database: <%= app_name %>_production username: DBA password: sql
The sqlanywhere.yml file provides a template for creating database.yml files in Rails projects. The following database options can be specified:
Update the Rails app_base.rb file. Using the same assumptions in the previous step, this file is located in the path \Ruby\lib\ruby\gems\1.9.1\gems\railties-3.1.3\lib\rails\generators\app_base.rb. Edit the app_base.rb file and locate the following line:
DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver )
Add sqlanywhere to the list as follows:
DATABASES = %w( sqlanywhere mysql oracle postgresql sqlite3 frontbase ibm_db sqlserver )
In the tutorial, you are shown the command to initialize the blog project. Here is the command to initialize the blog project for use with SAP Sybase IQ:
rails new blog -d sqlanywhere
After you create the blog application, switch to its folder to continue work directly in that application:
cd blog
Edit the gemfile file to include a gem directive for the SQL Anywhere ActiveRecord adapter. Add the new directive following the indicated line below:
gem 'sqlanywhere' gem 'activerecord-sqlanywhere-adapter'
The config\database.yml file references the development, test, and production databases. Instead of using a rake command to create the databases as indicated by the tutorial, change to the db directory of the project and create three databases as follows.
cd db iqinit -dba DBA,sql blog_development iqinit -dba DBA,sql blog_test iqinit -dba DBA,sql blog_production cd ..
You have configured Rails support in SAP Sybase IQ.
Start the database server and the three databases as follows.
iqsrv16 -n blog blog_development.db blog_production.db blog_test.db
The database server name in the command line (blog) must match the name specified by the server: tags in the database.yml file. The sqlanywhere.yml template file is configured to ensure that the database server name matches the project name in all generated database.yml files.