Preparing Your Project and Database
Before you can do anything, you’ll need a Rails project.
Create your project by typing rails photos, and
then change into the new directory with cd photos.
You’ll see the following output, which we’ve abbreviated; your exact list
may be different based on your version of Rails:
$ rails photos
create
create app/controllers
create app/helpers
create app/models
...
create config/database.yml
create config/routes.rb
...
$ cd photos/If your server is not started, restart it as usual with script/server. Point your browser to
http://localhost:3000/ to make sure things are
working. You’ll see the Rails welcome page if everything is working
correctly.
Let’s take a more detailed look at the files that Rails created with the new project. Notice that Rails created a database configuration file for you called database.yml. As of Rails 2, the default configuration file uses a lightweight database called sqlite3. You can use that database engine or another one, like MySQL. In this book, we’ll use sqlite3. If you decide to use MySQL instead, you would need to install the database engine, and change config/database.yml to match your database configuration, which would look something like this:
development: adapter: mysql database: photos_development username: root password: host: localhost test: adapter: mysql database: photos_development username: root password: host: localhost
If you choose to use MySQL or change your database.yml file in any way, keep in mind that ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access