I finally got a MySQL database hooked up to a Rails 3.2 app after spending half the day figuring it out.
What I don’t understand though is how Rails knows where to find the database?
With the default Sqlite3 it’s easy enough in that it’s embedded in the app so it’s just a matter of specifying the path in the database.yml (db/devlopment.sqlite3).
But, when it’s MySQL, I thought I’d have to specify the path of the database I’d created from the MySQL command line. Turns out I don’t have to, all I have to do is give the name of the database and user login credentials.
So when I run a migration in Rails, how does it know where the database is?
That’s called a reasonable default. Take a look in your
database.ymlfile, you might find a line like this:AFAIK, if that’s not explicitly there, it is used as the default in the absence of other parameters (such as
hostandport).