I started using Rails 2 last April but stopped this June because I thought learning it when Rails 3 was released would be more practical since a lot of it was completely refactored and restructured. I used to work with Ubuntu 10.04 (with SQLite3 as the default db) but now I'm using Windows 7 and MySQL 5. I already installed the gem adapter for MySQL, but to use it I still need to tweak database.yml. Thanks.
Rails defaults to using a SQLite database when creating a new project, but you can always change it later.
Now your Rails applications can use MySQL databases.
In terms of database configuration, nothing much has really changed between Rails 2 and 3 with the exception of how you load your MySQL driver. This used to be done in config/environment.rb
but is now done in Gemfile
:
gem 'mysql'
The default config/database.yml
file is set up with SQLite, but you can easily change this over to be MySQL. A generic version looks like:
defaults: &defaults
adapter: mysql
username: localdev
password: mylocaldevpasswordwhateveritis
host: localhost
development:
<<: *defaults
database: project_dev
test:
<<: *defaults
database: project_test
It's the adapter
declaration line that sets what driver to use.
In tadman's answer, use gem 'mysql2' for the rails 3 since rails 3 now uses the new mysql adapter !!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With