First you have to get the right stuff, depending on whether you are using native Ruby or JRuby:
If you are using a MySQL database, then Rails will work out-of-the-box. You have the option of installing the mysql gem, but doing so is not necessary. Some people say that the gem increases the speed of the database access.
For other database servers, consult the Ruby on Rails How-To pages. For example
See the Ruby on Rails Database Drivers page for the full list of supported drivers.
Again, if you are using a MySQL database, then Rails will work out-of-the-box. You can also access a MySQL database through JDBC. For more information, see Faq Rails JRuby Database Access and Using Database Servers With JRuby.
In order to access a database from your Rails project, you must set up the configurations in the project's database.yml file. Typically, you supply an adapter, database name, username (and password if necessary) and host, similar to the configuration below:
adapter: mysql database: my_development_database username: fred password: pfm host: localhost
When you create the project, the IDE automatically edits the database.yml based on the selections that you make in the third page of the wizard and the current Ruby interpreter (JRuby or native Ruby), as described below. If you use the defaults (MySQL and database names derived from the project name), you can skip page 3 altogether.