Need to create RoR app with MySQL

Asked By 0 points N/A Posted on -
qa-featured

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?

SHARE
Best Answer by Wanda Garcia
Best Answer
Best Answer
Answered By 0 points N/A #114655

Need to create RoR app with MySQL

qa-featured

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.

Related Questions