Asked By
sara.hassan
0 points
N/A
Posted on - 08/15/2011
I was using SQLite with Ruby on Rails but now I have switched to MySQL and I am unable to create a new RoR application using MySQL.
When I do 'rails AppName' it creates a new project but it isn't connected with MySQL.
So what do I create a new rails project using MySQL?
Need to create RoR app with MySQL
Use this command: rails new <project name> -d MySQL
You can also manually configure the database.yml in the config folder.
Sample database.yml:
development:
adapter: mysql
encoding: utf8
pool: 5
username: <your username>
password: <your password>
database: <your database name>
test:
adapter: mysql
encoding: utf8
pool: 5
username: <your username>
password: <your password>
database: <your database name>
production:
adapter: mysql
encoding: utf8
pool: 5
username: <your username>
password: <your password>
database: <your database name>
With this configuration, rails can support multiple databases.
One database for development, another one for test, and for production.
You can also use different database engine like for example you use sqlite for development and mysql for production.