last update: 2009-05-01 04:55:14 GMT This book is a work in progress; feel free to contribute.

The Merb Open Source Book
Français | 한국어 | 日本語 | Português | Deutsch | 中文 | Español | Русский | Bosanski | Nederlands | العربية | Български | Italiano

Setting Up DataMapper

Configure the Database Settings

Database settings are found in config/database.yml.

If you want to use sqlite3 for everything, you shouldn’t have to change anything. Move on with this section.

Everything MySQL

If you want everything to use mysql, then where it says:

development: &defaults
  # These are the settings for repository :default
  adapter:  sqlite3
  database: sample_development.db

change to

development: &defaults
  adapter: mysql
  database: app_name_development
  username: user
  password: pass
  host: localhost

Realistically, everything but the adapter and host lines can be whatever you want, as long as you have mysql setup the recognize the user.

Only Production MySQL

If you just want production to use MySQL, then leave the development part alone, but change the part that says

production:
  <<:       *defaults
  database: production.db

to

production:
  adapter: mysql
  database: app_name_development
  username: user
  password: pass
  host: localhost

NOTE

MySQL and SQLite have some slight differences. MySQL might get errors with certain types not setup right that SQLite doesn’t get. So you should do a little testing to make sure that MySQL is happy with all of your fields before you go live.

TODO Talk about setting up other DBs.