Choose the db adapter while creating a new application in rails

A lot of people are moving towards Ruby on Rails even at corporate level and giving up the standard Java, .Net way of developing websites for their customers. There are plenty of reasons for that, one of them being their argument that these languages are good at small level but are not scalable enough to solve the needs of corporate level customers. But now even developers who have been coding in java or other languages are increasing looking at solving their problems using frameworks such as Rails or Python/Django.  I believe the development curve of any language is steep only because of the time you want to devote to that language. I chose to devote some time to learn a few things in rails that makes life easy or atleast saves a bit of time. So lets see. lets make some rails stuff.

You would know that to create a new application all you need to do is type


rails new application_name

But this configures the application to use the sqlite3 database, If you want to use any other database, you would have to change it manually in the config->database.yml file. But there is a better way to do it, If you are sure, what database you are going to use, you can just specify it at the time to creating the application


rails new application_name -d mysql

The “-d” specifies the database name, you can use any of the databases from the list – mysql, oracle, postgresql, sqlite3, frontbase, ibm_db, sqlserver, jdbcmysql, jdbcsqlite3, jdbcpostgresql, jdbc.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.