From a92a43c64822cc1922124f0de85e1e67163f8056 Mon Sep 17 00:00:00 2001 From: Mike Gunderloy Date: Sun, 30 Nov 2008 07:08:33 -0600 Subject: Regenerate Guides HTML --- .../guides/html/getting_started_with_rails.html | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'railties/doc/guides/html/getting_started_with_rails.html') diff --git a/railties/doc/guides/html/getting_started_with_rails.html b/railties/doc/guides/html/getting_started_with_rails.html index 304c26a54f..4fc92f8ad7 100644 --- a/railties/doc/guides/html/getting_started_with_rails.html +++ b/railties/doc/guides/html/getting_started_with_rails.html @@ -566,6 +566,14 @@ http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite -->
$ rails blog -d postgresql
 
+

After you create the blog application, switch to its folder to continue work directly in that application:

+
+
+
$ cd blog
+

In any case, Rails will create a folder in your working directory called blog. Open up that folder and explore its contents. Most of the work in this tutorial will happen in the app/ folder, but here's a basic rundown on the function of each folder that Rails creates in a new application by default:

password:

Change the username and password in the development section as appropriate.

+

3.3.4. Creating the Database

+

Now that you have your database configured, it's time to have Rails create an empty database for you. You can do this by running a rake command:

+
+
+
$ rake db:create
+

4. Hello, Rails!

@@ -1031,7 +1048,7 @@ http://www.gnu.org/software/src-highlite --> end

If you were to translate that into words, it says something like: when this migration is run, create a table named posts with two string columns (name and title) and a text column (content), and generate timestamp fields to track record creation and updating. You can learn the detailed syntax for migrations in the Rails Database Migrations guide.

-

At this point, you need to do two things: create the database and run the migration. You can use rake commands at the terminal for both of those tasks:

+

At this point, you can use a rake command to run the migration:

At this point, it’s worth looking at some of the tools that Rails provides to eliminate duplication in your code. In particular, you can use partials to clean up duplication in views and filters to help with duplication in controllers.

7.1. Using Partials to Eliminate View Duplication

-

As you saw earlier, the scaffold-generated views for the new and edit actions are largely identical. You can pull the shared code out into a partial template. This requires editing the new and edit views, and adding a new template:

+

As you saw earlier, the scaffold-generated views for the new and edit actions are largely identical. You can pull the shared code out into a partial template. This requires editing the new and edit views, and adding a new template. The new _form.html.erb template should be saved in the same app/views/posts folder as the files from which it is being extracted:

new.html.erb: