aboutsummaryrefslogtreecommitdiffstats
path: root/railties/doc
diff options
context:
space:
mode:
Diffstat (limited to 'railties/doc')
-rw-r--r--railties/doc/guides/bechmarking and profiling/.DS_Storebin6148 -> 0 bytes
-rw-r--r--railties/doc/guides/bechmarking and profiling/Examples/.DS_Storebin6148 -> 0 bytes
-rw-r--r--railties/doc/guides/benchmarking_and_profiling/Basics.html (renamed from railties/doc/guides/bechmarking and profiling/Basics.html)0
-rw-r--r--railties/doc/guides/benchmarking_and_profiling/Examples/graph.html (renamed from railties/doc/guides/bechmarking and profiling/Examples/graph.html)0
-rw-r--r--railties/doc/guides/benchmarking_and_profiling/Images/KGraph.png (renamed from railties/doc/guides/bechmarking and profiling/Images/KGraph.png)bin92342 -> 92342 bytes
-rw-r--r--railties/doc/guides/benchmarking_and_profiling/Images/KList.png (renamed from railties/doc/guides/bechmarking and profiling/Images/KList.png)bin20323 -> 20323 bytes
-rw-r--r--railties/doc/guides/benchmarking_and_profiling/appendix.txt (renamed from railties/doc/guides/bechmarking and profiling/appendix.txt)0
-rw-r--r--railties/doc/guides/benchmarking_and_profiling/basics.txt (renamed from railties/doc/guides/bechmarking and profiling/basics.txt)0
-rw-r--r--railties/doc/guides/benchmarking_and_profiling/definitions.txt (renamed from railties/doc/guides/bechmarking and profiling/definitions.txt)0
-rw-r--r--railties/doc/guides/benchmarking_and_profiling/digging_deeper.txt (renamed from railties/doc/guides/bechmarking and profiling/digging_deeper.txt)0
-rw-r--r--railties/doc/guides/benchmarking_and_profiling/edge rails features.txt (renamed from railties/doc/guides/bechmarking and profiling/edge rails features.txt)0
-rw-r--r--railties/doc/guides/benchmarking_and_profiling/gameplan.txt (renamed from railties/doc/guides/bechmarking and profiling/gameplan.txt)0
-rw-r--r--railties/doc/guides/benchmarking_and_profiling/preamble.html (renamed from railties/doc/guides/bechmarking and profiling/preamble.html)0
-rw-r--r--railties/doc/guides/benchmarking_and_profiling/preamble.txt (renamed from railties/doc/guides/bechmarking and profiling/preamble.txt)0
-rw-r--r--railties/doc/guides/benchmarking_and_profiling/rubyprof.txt (renamed from railties/doc/guides/bechmarking and profiling/rubyprof.txt)0
-rw-r--r--railties/doc/guides/benchmarking_and_profiling/statistics.txt (renamed from railties/doc/guides/bechmarking and profiling/statistics.txt)0
-rw-r--r--railties/doc/guides/getting_started_with_rails/getting_started_with_rails.txt37
-rw-r--r--railties/doc/guides/index.txt63
-rw-r--r--railties/doc/guides/routing/routing_outside_in.txt68
19 files changed, 138 insertions, 30 deletions
diff --git a/railties/doc/guides/bechmarking and profiling/.DS_Store b/railties/doc/guides/bechmarking and profiling/.DS_Store
deleted file mode 100644
index d933a198e6..0000000000
--- a/railties/doc/guides/bechmarking and profiling/.DS_Store
+++ /dev/null
Binary files differ
diff --git a/railties/doc/guides/bechmarking and profiling/Examples/.DS_Store b/railties/doc/guides/bechmarking and profiling/Examples/.DS_Store
deleted file mode 100644
index 5008ddfcf5..0000000000
--- a/railties/doc/guides/bechmarking and profiling/Examples/.DS_Store
+++ /dev/null
Binary files differ
diff --git a/railties/doc/guides/bechmarking and profiling/Basics.html b/railties/doc/guides/benchmarking_and_profiling/Basics.html
index 5cf3939fd6..5cf3939fd6 100644
--- a/railties/doc/guides/bechmarking and profiling/Basics.html
+++ b/railties/doc/guides/benchmarking_and_profiling/Basics.html
diff --git a/railties/doc/guides/bechmarking and profiling/Examples/graph.html b/railties/doc/guides/benchmarking_and_profiling/Examples/graph.html
index 807a405284..807a405284 100644
--- a/railties/doc/guides/bechmarking and profiling/Examples/graph.html
+++ b/railties/doc/guides/benchmarking_and_profiling/Examples/graph.html
diff --git a/railties/doc/guides/bechmarking and profiling/Images/KGraph.png b/railties/doc/guides/benchmarking_and_profiling/Images/KGraph.png
index fecdcd0531..fecdcd0531 100644
--- a/railties/doc/guides/bechmarking and profiling/Images/KGraph.png
+++ b/railties/doc/guides/benchmarking_and_profiling/Images/KGraph.png
Binary files differ
diff --git a/railties/doc/guides/bechmarking and profiling/Images/KList.png b/railties/doc/guides/benchmarking_and_profiling/Images/KList.png
index 57b3568832..57b3568832 100644
--- a/railties/doc/guides/bechmarking and profiling/Images/KList.png
+++ b/railties/doc/guides/benchmarking_and_profiling/Images/KList.png
Binary files differ
diff --git a/railties/doc/guides/bechmarking and profiling/appendix.txt b/railties/doc/guides/benchmarking_and_profiling/appendix.txt
index edda9607ed..edda9607ed 100644
--- a/railties/doc/guides/bechmarking and profiling/appendix.txt
+++ b/railties/doc/guides/benchmarking_and_profiling/appendix.txt
diff --git a/railties/doc/guides/bechmarking and profiling/basics.txt b/railties/doc/guides/benchmarking_and_profiling/basics.txt
index 24174efc7e..24174efc7e 100644
--- a/railties/doc/guides/bechmarking and profiling/basics.txt
+++ b/railties/doc/guides/benchmarking_and_profiling/basics.txt
diff --git a/railties/doc/guides/bechmarking and profiling/definitions.txt b/railties/doc/guides/benchmarking_and_profiling/definitions.txt
index 3ba3cc41e0..3ba3cc41e0 100644
--- a/railties/doc/guides/bechmarking and profiling/definitions.txt
+++ b/railties/doc/guides/benchmarking_and_profiling/definitions.txt
diff --git a/railties/doc/guides/bechmarking and profiling/digging_deeper.txt b/railties/doc/guides/benchmarking_and_profiling/digging_deeper.txt
index 73a72e1264..73a72e1264 100644
--- a/railties/doc/guides/bechmarking and profiling/digging_deeper.txt
+++ b/railties/doc/guides/benchmarking_and_profiling/digging_deeper.txt
diff --git a/railties/doc/guides/bechmarking and profiling/edge rails features.txt b/railties/doc/guides/benchmarking_and_profiling/edge rails features.txt
index ede1c5831e..ede1c5831e 100644
--- a/railties/doc/guides/bechmarking and profiling/edge rails features.txt
+++ b/railties/doc/guides/benchmarking_and_profiling/edge rails features.txt
diff --git a/railties/doc/guides/bechmarking and profiling/gameplan.txt b/railties/doc/guides/benchmarking_and_profiling/gameplan.txt
index 578a70ebaa..578a70ebaa 100644
--- a/railties/doc/guides/bechmarking and profiling/gameplan.txt
+++ b/railties/doc/guides/benchmarking_and_profiling/gameplan.txt
diff --git a/railties/doc/guides/bechmarking and profiling/preamble.html b/railties/doc/guides/benchmarking_and_profiling/preamble.html
index b52b8a7e74..b52b8a7e74 100644
--- a/railties/doc/guides/bechmarking and profiling/preamble.html
+++ b/railties/doc/guides/benchmarking_and_profiling/preamble.html
diff --git a/railties/doc/guides/bechmarking and profiling/preamble.txt b/railties/doc/guides/benchmarking_and_profiling/preamble.txt
index bba8217793..bba8217793 100644
--- a/railties/doc/guides/bechmarking and profiling/preamble.txt
+++ b/railties/doc/guides/benchmarking_and_profiling/preamble.txt
diff --git a/railties/doc/guides/bechmarking and profiling/rubyprof.txt b/railties/doc/guides/benchmarking_and_profiling/rubyprof.txt
index edf036d13e..edf036d13e 100644
--- a/railties/doc/guides/bechmarking and profiling/rubyprof.txt
+++ b/railties/doc/guides/benchmarking_and_profiling/rubyprof.txt
diff --git a/railties/doc/guides/bechmarking and profiling/statistics.txt b/railties/doc/guides/benchmarking_and_profiling/statistics.txt
index c3b4464d4b..c3b4464d4b 100644
--- a/railties/doc/guides/bechmarking and profiling/statistics.txt
+++ b/railties/doc/guides/benchmarking_and_profiling/statistics.txt
diff --git a/railties/doc/guides/getting_started_with_rails/getting_started_with_rails.txt b/railties/doc/guides/getting_started_with_rails/getting_started_with_rails.txt
index 2805e5629d..3259ef8a45 100644
--- a/railties/doc/guides/getting_started_with_rails/getting_started_with_rails.txt
+++ b/railties/doc/guides/getting_started_with_rails/getting_started_with_rails.txt
@@ -317,7 +317,42 @@ This time, we're setting `@post` to a single record in the database that is sear
==== New & Create
-Description of new and create actions
+In your controller, you'll see the `new` and `create` actions, which are used together to create a new record. Our `new` action simply instantiates a new Post object without any parameters:
+
+-----------------------------------------
+def new
+ @post = Post.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @post }
+ end
+end
+----------------------------------------
+
+Our `create` action, on the other hand, instantiates a new Post object while setting its attributes to the parameters that we specify in our form. It then uses a `flash[:notice]` to inform the user of the status of the action. If the Post is saved successfully, the action will redirect to the `show` action containing our new Post simply by calling the simple `redirect_to(@post)`.
+
+.The Flash
+**************************************************************************************************************
+Rails provides the Flash so that messages can be carried over to another action, providing the user with useful information on the status of their request. In our `create` example, the user never actually sees any page rendered during the Post creation process, because it immediately redirects to the new Post as soon as the record is saved. The Flash allows us to carry over a message to the next action, so once the user is redirected back to the `show` action, they are presented with a message saying "Post was successfully created."
+**************************************************************************************************************
+
+----------------------------------------
+def create
+ @post = Post.new(params[:post])
+
+ respond_to do |format|
+ if @post.save
+ flash[:notice] = 'Post was successfully created.'
+ format.html { redirect_to(@post) }
+ format.xml { render :xml => @post, :status => :created, :location => @post }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
+ end
+ end
+end
+---------------------------------------
==== Edit & Update
diff --git a/railties/doc/guides/index.txt b/railties/doc/guides/index.txt
index 45002f874a..402037a7d1 100644
--- a/railties/doc/guides/index.txt
+++ b/railties/doc/guides/index.txt
@@ -3,28 +3,60 @@ Ruby on Rails guides
WARNING: This page is the result of ongoing http://hackfest.rubyonrails.org/guide[Rails Guides hackfest] and a work in progress.
-.link:getting_started_with_rails/getting_started_with_rails.html[Getting Started with Rails]
+++++++++++++++++++++++++++++++++++++++
+<h2>Finished Guides</h2>
+++++++++++++++++++++++++++++++++++++++
+
+These guides are complete and the authors are listed link:authors.html[here].
+
+.link:migrations/migrations.html[Rails Database Migrations]
***********************************************************
TODO: Insert some description here.
***********************************************************
-.link:activerecord/association_basics.html[Active Record Associations]
+.link:routing/routing_outside_in.html[Rails Routing from the Outside In]
***********************************************************
-Introduction to Active Record associations.
+This guide covers the user-facing features of Rails routing. If you want to
+understand how to use routing in your own Rails applications, start here.
***********************************************************
-.link:migrations/migrations.html[Rails Database Migrations]
+++++++++++++++++++++++++++++++++++++++
+<h2>Guides in progress</h2>
+++++++++++++++++++++++++++++++++++++++
+
+These guides are currently being worked on. While they still might be useful to you, you could always help by reviewing them and posting your
+findings at the respective Lighthouse ticket.
+
+.link:debugging/debugging_rails_applications.html[Debugging Rails Applications]
***********************************************************
-TODO: Insert some description here.
+link:http://rails.lighthouseapp.com/projects/16213/tickets/5[Lighthouse Ticket]
+
+This guide describes how to debug Rails applications. It covers the different
+ways of achieving this and how to understand what is happening "behind the scenes"
+of your code.
+***********************************************************
+
+.link:getting_started_with_rails/getting_started_with_rails.html[Getting Started with Rails]
+***********************************************************
+link:http://rails.lighthouseapp.com/projects/16213/tickets/2[Lighthouse Ticket]
+***********************************************************
+
+.link:activerecord/association_basics.html[Active Record Associations]
+***********************************************************
+link:http://rails.lighthouseapp.com/projects/16213/tickets/11[Lighthouse Ticket]
***********************************************************
.link:forms/form_helpers.html[Action View Form Helpers]
***********************************************************
+link:http://rails.lighthouseapp.com/projects/16213/tickets/1[Lighthouse Ticket]
+
Guide to using built in Form helpers.
***********************************************************
.link:testing_rails_applications/testing_rails_applications.html[Testing Rails Applications]
***********************************************************
+link:http://rails.lighthouseapp.com/projects/16213/tickets/8[Lighthouse Ticket]
+
This is a rather comprehensive guide to doing both unit and functional tests
in Rails. It covers everything from ``What is a test?'' to the testing APIs.
Enjoy.
@@ -32,29 +64,20 @@ Enjoy.
.link:securing_rails_applications/security.html[Securing Rails Applications]
***********************************************************
+link:http://rails.lighthouseapp.com/projects/16213/tickets/7[Lighthouse Ticket]
+
This manual describes common security problems in web applications and how to
avoid them with Rails.
***********************************************************
-.link:routing/routing_outside_in.html[Rails Routing from the Outside In]
-***********************************************************
-This guide covers the user-facing features of Rails routing. If you want to
-understand how to use routing in your own Rails applications, start here.
+.link:caching/caching_with_rails.html[Rails Caching]
***********************************************************
+link:http://rails.lighthouseapp.com/projects/16213/tickets/10[Lighthouse Ticket]
-.link:debugging/debugging_rails_applications.html[Debugging Rails Applications]
-***********************************************************
-This guide describes how to debug Rails applications. It covers the different
-ways of achieving this and how to understand what is happening "behind the scenes"
-of your code.
+TODO: Insert some description here.
***********************************************************
.link:creating_plugins/creating_plugins.html[The Basics of Creating Rails Plugins]
***********************************************************
-TODO: Insert some description here.
+TODO: Insert some description here. No Lighthouse ticket.
***********************************************************
-
-.link:caching/caching_with_rails.html[Rails Caching]
-***********************************************************
-TODO: Insert some description here.
-*********************************************************** \ No newline at end of file
diff --git a/railties/doc/guides/routing/routing_outside_in.txt b/railties/doc/guides/routing/routing_outside_in.txt
index 2e48ca59b7..29b69ab47d 100644
--- a/railties/doc/guides/routing/routing_outside_in.txt
+++ b/railties/doc/guides/routing/routing_outside_in.txt
@@ -168,6 +168,24 @@ photos_url # => "http://www.example.com/photos"
photos_path # => "/photos"
-------------------------------------------------------
+=== Defining Multiple Resources at the Same Time
+
+If you need to create routes for more than one RESTful resource, you can save a bit of typing by defining them all with a single call to +map.resources+:
+
+[source, ruby]
+-------------------------------------------------------
+map.resources :photos, :books, :videos
+-------------------------------------------------------
+
+This has exactly the same effect as
+
+[source, ruby]
+-------------------------------------------------------
+map.resources :photos
+map.resources :books
+map.resources :videos
+-------------------------------------------------------
+
=== Singular Resources
You can also apply RESTful routing to singleton resources within your application. In this case, you use +map.resource+ instead of +map.resources+ and the route generation is slightly different. For example, a routing entry of
@@ -379,11 +397,11 @@ HTTP verb URL controller action used for
--------------------------------------------------------------------------------------------
GET /magazines/1/ads Ads index display a list of all ads for a specific magazine
GET /magazines/1/ads/new Ads new return an HTML form for creating a new ad belonging to a specific magazine
-POST /magazines/1/ads Ads create create a new photo belonging to a specific magazine
-GET /magazines/1/ads/1 Ads show display a specific photo belonging to a specific magazine
-GET /magazines/1/ads/1/edit Ads edit return an HTML form for editing a photo belonging to a specific magazine
-PUT /magazines/1/ads/1 Ads update update a specific photo belonging to a specific magazine
-DELETE /magazines/1/ads/1 Ads destroy delete a specific photo belonging to a specific magazine
+POST /magazines/1/ads Ads create create a new ad belonging to a specific magazine
+GET /magazines/1/ads/1 Ads show display a specific ad belonging to a specific magazine
+GET /magazines/1/ads/1/edit Ads edit return an HTML form for editing an ad belonging to a specific magazine
+PUT /magazines/1/ads/1 Ads update update a specific ad belonging to a specific magazine
+DELETE /magazines/1/ads/1 Ads destroy delete a specific ad belonging to a specific magazine
--------------------------------------------------------------------------------------------
This will also create routing helpers such as +magazine_ads_url+ and +magazine_edit_ad_path+.
@@ -499,6 +517,29 @@ If you like, you can combine shallow nesting with the +:has_one+ and +:has_many+
map.resources :publishers, :has_many => { :magazines => :photos }, :shallow => true
-------------------------------------------------------
+=== Namespaced Resources
+
+It's possible to do some quite complex things by combining +:path_prefix+ and +:name_prefix+. For example, you can use the combination of these two options to move administrative resources to their own folder in your application:
+
+[source, ruby]
+-------------------------------------------------------
+map.resources :photos, :path_prefix => 'admin', :controller => 'admin/photos'
+map.resources :tags, :path_prefix => 'admin_photo_', :path_prefix => 'admin/photos/:photo_id', :controller => 'admin/photo_tags'
+map.resources :ratings, :path_prefix => 'admin_photo_', :path_prefix => 'admin/photos/:photo_id', :controller => 'admin/photo_ratings'
+-------------------------------------------------------
+
+The good news is that if you find yourself using this level of complexity, you can stop. Rails supports _namespaced resources_ to make placing resources in their own folder a snap. Here's the namespaced version of those same three routes:
+
+[source, ruby]
+-------------------------------------------------------
+map.namespace(:admin) do |admin|
+ admin.resources :photos,
+ :has_many => { :tags, :ratings}
+end
+-------------------------------------------------------
+
+As you can see, the namespaced version is much more succinct than the one that spells everything out - but it still creates the same routes. For example, you'll get +admin_photos_url+ that expects to find an +Admin::PhotosController+ and that matches +admin/photos+, and +admin_photos_ratings+path+ that matches +/admin/photos/_photo_id_/ratings+, expecting to use +Admin::RatingsController+.
+
=== Adding More RESTful Actions
You are not limited to the seven routes that RESTful routing creates by default. If you like, you may add additional member routes (those which apply to a single instance of the resource), additional new routes (those that apply to creating a new resource), or additional collection routes (those which apply to the collection of resources as a whole).
@@ -574,7 +615,7 @@ You can set up as many wildcard symbols within a regular route as you like. Anyt
[source, ruby]
-------------------------------------------------------
-map.connect ':controller/:action/:id/:userid:'
+map.connect ':controller/:action/:id/:user_id'
-------------------------------------------------------
An incoming URL of +/photos/show/1/2+ will be dispatched to the +show+ action of the +Photos+ controller. +params[:id]+ will be set to 1, and +params[:user_id]+ will be set to 2.
@@ -585,7 +626,7 @@ You can specify static text when creating a route. In this case, the static text
[source, ruby]
-------------------------------------------------------
-map.connect ':controller/:action/:id/with_user/:userid:'
+map.connect ':controller/:action/:id/with_user/:user_id'
-------------------------------------------------------
This route would respond to URLs such as +/photos/show/1/with_user/2+.
@@ -612,6 +653,15 @@ map.connect 'photo/:id', :controller => 'photos', :action => 'show'
With this route, an incoming URL of +/photos/12+ would be dispatched to the +show+ action within the +Photos+ controller.
+You an also define other defaults in a route by supplying a hash for the +:defaults+ option. This even applies to parameters that are not explicitly defined elsewhere in the route. For example:
+
+[source, ruby]
+-------------------------------------------------------
+map.connect 'photo/:id', :controller => 'photos', :action => 'show', :defaults => { :format => 'jpg' }
+-------------------------------------------------------
+
+With this route, an incoming URL of +photos/12+ would be dispatched to the +show+ action within the +Photos+ controller, and +params[:format]+ will be set to +jpg+.
+
=== Named Routes
Regular routes need not use the +connect+ method. You can use any other name here to create a _named route_. For example,
@@ -655,7 +705,7 @@ As with conditions in RESTful routes, you can specify +:get+, +:post+, +:put+, +
=== Route Globbing
-Route globbing is a way to specify that a particular parameter (which must be the last parameter in the route) should engulf all the remaining parts of a route. For example
+Route globbing is a way to specify that a particular parameter (which must be the last parameter in the route) should be matched to all the remaining parts of a route. For example
[source, ruby]
-------------------------------------------------------
@@ -690,7 +740,7 @@ For instance, consider the second of the default routes in the boilerplate +rout
map.connect ':controller/:action/:id.:format'
-------------------------------------------------------
-This route matches requests such as +/photo/new/1.xml+ or +/photo/show/2.rss+. Within the appropriate action code, you can issue different responses depending on the requested format:
+This route matches requests such as +/photo/edit/1.xml+ or +/photo/show/2.rss+. Within the appropriate action code, you can issue different responses depending on the requested format:
[source, ruby]
-------------------------------------------------------