Ruby Forum Ruby on Rails > How to get rails command to default to MySQL instead of SQLite?

Posted by Mira Vol (miravol)
on 05.11.2007 05:07
(Received via mailing list)
I'm running OS/X 10.5 Leopard. Although I have MySQL installed the
rails command creates a database.yml file that defaults to SQLite. How
do I get it to default to MySQL instead?

TIA
Posted by Brian Hogan (Guest)
on 05.11.2007 05:28
(Received via mailing list)
Hmmm.

The Rails default is actually mysql. I haven't looked at what they 
changed
in 10.5 as I am still running my own build of Ruby and Rails.

You can force the db type though.

rails my_new_app --database=mysql
Posted by William Pratt (Guest)
on 05.11.2007 05:35
(Received via mailing list)
Hmm, sure enough:

#the pre-installed rails:
macbookpro: wpratt$ /usr/bin/rails
... snip ...
-d, --database=name              Preconfigure for selected database
(options: mysql/oracle/postgresql/sqlite2/sqlite3).
                                      Default: sqlite3

#and from my own stack:

macbookpro: wpratt$ /usr/local/bin/rails
... snip ...
-d, --database=name              Preconfigure for selected database
(options: mysql/oracle/postgresql/sqlite2/sqlite3).
                                      Default: mysql

I guess this makes sense since Leopard doesn't ship with mysql but
does ship with sqlite3.

-Bill
Posted by gmlk (Guest)
on 05.11.2007 08:49
(Received via mailing list)
On Nov 5, 5:06 am, "mira...@gmail.com" <mira...@gmail.com> wrote:
> I'm running OS/X 10.5 Leopard. Although I have MySQL installed the
> rails command creates a database.yml file that defaults to SQLite. How
> do I get it to default to MySQL instead?
>
> TIA

The quick&dirty way is to edit

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
gems/1.8/gems/rails-1.2.3/lib/rails_generator/generators/applications/
app/app_generator.rb

on lines 9 and 104 (replace sqlite3 with mysql)

Or you could install rails version 1.2.5; which defaults again to
mysql.
Rails 1.2.5 is then installed in /Library/Ruby/Gems/1.8/gems/
rails-1.2.5/

Personally I like sqlite3 as the default and would like to know how to
tell gem to use this as the default. Setting the shell variable
RAILS_DEFAULT_DATABASE doesn't seem to work.