Set MySQL as Default Adaptor for All New Rails Applications
I started learning small and smart tips for rails by following Railcasts.com. In order to try out a trick, every time I need to create a application.
Normally it was like
rails new railscast_xx -d mysql
Some times even when I forget to mention the mysql version, then need to go Gemfile and add Gem.
1 2 3 4 5
Then open database.yml to change the settings and start afresh. It was always a mess to spend time over and again on same thing, untill I found a permanent solution to this here on stackoverflow. One needs to just edit the file in rails code and change mysql as default instead of sqlite3.
vi $(rvm gemdir)/gems/railties-3.2.13/lib/rails/generators/app_base.rb
This opens up vi editor with file app_base.rb(any other editor can also be used). Search for
and change this to
Now every time you try creating any rails application, it by default choses mysql as your prefered datbase. Adds gem to Gemfile and creates database.yml accordingly. ;)