aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/getting_started.textile
diff options
context:
space:
mode:
Diffstat (limited to 'railties/guides/source/getting_started.textile')
-rw-r--r--railties/guides/source/getting_started.textile34
1 files changed, 21 insertions, 13 deletions
diff --git a/railties/guides/source/getting_started.textile b/railties/guides/source/getting_started.textile
index 6aca5d3420..1bdfd79476 100644
--- a/railties/guides/source/getting_started.textile
+++ b/railties/guides/source/getting_started.textile
@@ -9,7 +9,7 @@ This guide covers getting up and running with Ruby on Rails. After reading it, y
endprologue.
-WARNING. This Guide is based on Rails 3.0. Some of the code shown here will not work in earlier versions of Rails.
+WARNING. This Guide is based on Rails 3.1. Some of the code shown here will not work in earlier versions of Rails.
h3. Guide Assumptions
@@ -20,6 +20,7 @@ This guide is designed for beginners who want to get started with a Rails applic
TIP: Note that Ruby 1.8.7 p248 and p249 have marshaling bugs that crash Rails 3.0. Ruby Enterprise Edition have these fixed since release 1.8.7-2010.02 though. On the 1.9 front, Ruby 1.9.1 is not usable because it outright segfaults on Rails 3.0, so if you want to use Rails 3 with 1.9.x jump on 1.9.2 for smooth sailing.
* The "RubyGems":http://rubyforge.org/frs/?group_id=126 packaging system
+ ** If you want to learn more about RubyGems, please read the "RubyGems User Guide":http://docs.rubygems.org/read/book/1
* A working installation of the "SQLite3 Database":http://www.sqlite.org
Rails is a web application framework running on the Ruby programming language. If you have no prior experience with Ruby, you will find a very steep learning curve diving straight into Rails. There are some good free resources on the internet for learning Ruby, including:
@@ -50,7 +51,7 @@ At the core of Rails is the Model, View, Controller architecture, usually just c
h5. Models
-A model represents the information (data) of the application and the rules to manipulate that data. In the case of Rails, models are primarily used for managing the rules of interaction with a corresponding database table. In most cases, one table in your database will correspond to one model in your application. The bulk of your application's business logic will be concentrated in the models.
+A model represents the information (data) of the application and the rules to manipulate that data. In the case of Rails, models are primarily used for managing the rules of interaction with a corresponding database table. In most cases, each table in your database will correspond to one model in your application. The bulk of your application's business logic will be concentrated in the models.
h5. Views
@@ -62,7 +63,8 @@ Controllers provide the "glue" between models and views. In Rails, controllers a
h4. The Components of Rails
-Rails ships as many individual components.
+Rails ships as many individual components. Each of these components are briefly explained below. If you are new to Rails, as you read this section, don't get hung up on the details of each component, as they will be
+explained in further detail later. For instance, we will bring up Rack applications, but you don't need to know anything about them to continue with this guide.
* Action Pack
** Action Controller
@@ -80,17 +82,19 @@ h5. Action Pack
Action Pack is a single gem that contains Action Controller, Action View and Action Dispatch. The "VC" part of "MVC".
-h5. Action Controller
+h6. Action Controller
Action Controller is the component that manages the controllers in a Rails application. The Action Controller framework processes incoming requests to a Rails application, extracts parameters, and dispatches them to the intended action. Services provided by Action Controller include session management, template rendering, and redirect management.
-h5. Action View
+h6. Action View
-Action View manages the views of your Rails application. It can create both HTML and XML output by default. Action View manages rendering templates, including nested and partial templates, and includes built-in AJAX support.
+Action View manages the views of your Rails application. It can create both HTML and XML output by default. Action View
+manages rendering templates, including nested and partial templates, and includes built-in AJAX support. View templates
+are covered in more detail in another guide called "Layouts and Rendering":layouts_and_rendering.html.
-h5. Action Dispatch
+h6. Action Dispatch
-Action Dispatch handles routing of web requests and dispatches them as you want, either to your application or any other Rack application.
+Action Dispatch handles routing of web requests and dispatches them as you want, either to your application or any other Rack application. Rack applications are a more advanced topic and are covered in a separate guide called "Rails on Rack":rails_on_rack.html.
h5. Action Mailer
@@ -174,9 +178,9 @@ $ cd blog
In any case, Rails will create a folder in your working directory called <tt>blog</tt>. Open up that folder and explore its contents. Most of the work in this tutorial will happen in the <tt>app/</tt> folder, but here's a basic rundown on the function of each folder that Rails creates in a new application by default:
|_.File/Folder|_.Purpose|
-|Gemfile|This file allows you to specify what gem dependencies are needed for your Rails application.|
-|README|This is a brief instruction manual for your application. Use it to tell others what your application does, how to set it up, and so on.|
-|Rakefile|This file contains batch jobs that can be run from the terminal.|
+|Gemfile|This file allows you to specify what gem dependencies are needed for your Rails application. See section on Bundler, below.|
+|README|This is a brief instruction manual for your application. You should edit this file to tell others what your application does, how to set it up, and so on.|
+|Rakefile|This file locates and loads tasks that can be run from the command line. The task definitions are defined throughout the components of Rails. Rather than changing Rakefile, you should add your own tasks by adding files to the lib/tasks directory of your application.|
|app/|Contains the controllers, models, views and assets for your application. You'll focus on this folder for the remainder of this guide.|
|config/|Configure your application's runtime rules, routes, database, and more.|
|config.ru|Rack configuration for Rack based servers used to start the application.|
@@ -386,7 +390,7 @@ $ rails generate scaffold Post name:string title:string content:text
NOTE. While scaffolding will get you up and running quickly, the code it generates is unlikely to be a perfect fit for your application. You'll most probably want to customize the generated code. Many experienced Rails developers avoid scaffolding entirely, preferring to write all or most of their source code from scratch. Rails, however, makes it really simple to customize templates for generated models, controllers, views and other source files. You'll find more information in the "Creating and Customizing Rails Generators & Templates":generators.html guide.
-The scaffold generator will build 15 files in your application, along with some folders, and edit one more. Here's a quick overview of what it creates:
+The scaffold generator will build 17 files in your application, along with some folders, and edit one more. Here's a quick overview of what it creates:
|_.File |_.Purpose|
|db/migrate/20100207214725_create_posts.rb |Migration to create the posts table in your database (your name will include a different timestamp)|
@@ -400,6 +404,8 @@ The scaffold generator will build 15 files in your application, along with some
|app/views/posts/_form.html.erb |A partial to control the overall look and feel of the form used in edit and new views|
|app/helpers/posts_helper.rb |Helper functions to be used from the post views|
|app/assets/stylesheets/scaffold.css.scss |Cascading style sheet to make the scaffolded views look better|
+|app/assets/stylesheets/post.css.scss |Cascading style sheet for the posts controller|
+|app/assets/javascripts/post.js.coffee |CoffeeScript for the posts controller|
|test/unit/post_test.rb |Unit testing harness for the posts model|
|test/functional/posts_controller_test.rb |Functional testing harness for the posts controller|
|test/unit/helpers/posts_helper_test.rb |Unit testing harness for the posts helper|
@@ -920,13 +926,15 @@ With the model in hand, you can turn your attention to creating a matching contr
$ rails generate controller Comments
</shell>
-This creates four files and one empty directory:
+This creates six files and one empty directory:
* +app/controllers/comments_controller.rb+ - The controller
* +app/helpers/comments_helper.rb+ - A view helper file
* +test/functional/comments_controller_test.rb+ - The functional tests for the controller
* +test/unit/helpers/comments_helper_test.rb+ - The unit tests for the helper
* +app/views/comments/+ - Views of the controller are stored here
+* +app/assets/stylesheets/comment.css.scss+ - Cascading style sheet for the controller
+* +app/assets/javascripts/comment.js.coffee+ - CoffeeScript for the controller
Like with any blog, our readers will create their comments directly after reading the post, and once they have added their comment, will be sent back to the post show page to see their comment now listed. Due to this, our +CommentsController+ is there to provide a method to create comments and delete SPAM comments when they arrive.