<— TutorialStepOne | TutorialStepThree (Creating a controller) —>
Edit config/database.yml with your database settings. Adapter-specific samples are shown below.
Note: No tabs allowed in database.yml, make sure you only use spaces.
If you’re using MySQL, your setup should look like:
development: adapter: mysql database: rails_development host: localhost username: rails_user password: [your password here] test: adapter: mysql database: rails_test host: localhost username: rails_user password: [your password here] production: adapter: mysql database: rails_production host: localhost username: rails_user password: [your password here]
Since we’re developing, we’ll be running Rails in development mode. We won’t really need the production settings, however we’ve filled them in for completeness’ sake.
Also note that rails_production is the actual name of the database we’ve just created. It could be anything, and the _production part doesn’t put rails into production mode.
Mac users: Assuming your MySQL installation is based on the MAMP package, you will need to add the following line to each database configuration set listed above:
socket: /Applications/MAMP/tmp/mysql/mysql.sock
If you’re using SQLite, your setup should look something like:
production: adapter: sqlite3 # Use sqlite (no 3) for 1/2.x dbfile: db/rails-production.db test: adapter: sqlite3 # Use sqlite (no 3) for 1/2.x dbfile: db/rails-test.db development: adapter: sqlite3 # Use sqlite (no 3) for 1/2.x dbfile: db/rails-development.db
Note that prior to being able to use the SQLite adapter, you will need to have the sqlite.dll in a directory on your path (in win32) such as your ruby\bin directory, and install the appropriate gem (everyone):
gem install sqlite3-ruby # for SQLite3 or gem install sqlite-ruby # for an earlier 2.x release
Win32 users should choose the highest numbered “-win” entry, and linux should choose the highest numbered “-ruby” entry.
If you’re using PostgreSQL, your setup should look something like:
production: adapter: postgresql database: rails_production username: postgres password: test: adapter: postgresql database: rails_test username: postgres password: development: adapter: postgresql database: rails_development username: postgres password:
<— TutorialStepOne | TutorialStepThree (Creating a controller) —>