Browse files

Merge with docrails

  • Loading branch information...
1 parent a03e2b3 commit 896058b485653bc8a1b5ccbc1248267880a8c911 @lifo lifo committed Oct 22, 2008
Showing with 304 additions and 137 deletions.
  1. +1 −2 railties/Rakefile
  2. +5 −5 railties/doc/guides/html/actioncontroller_basics.html
  3. +16 −16 railties/doc/guides/html/association_basics.html
  4. +1 −1 railties/doc/guides/html/benchmarking_and_profiling.html
  5. +2 −2 railties/doc/guides/html/creating_plugins.html
  6. +9 −9 railties/doc/guides/html/debugging_rails_applications.html
  7. +121 −20 railties/doc/guides/html/finders.html
  8. +9 −9 railties/doc/guides/html/form_helpers.html
  9. +14 −14 railties/doc/guides/html/getting_started_with_rails.html
  10. +11 −11 railties/doc/guides/html/index.html
  11. +13 −13 railties/doc/guides/html/layouts_and_rendering.html
  12. +3 −3 railties/doc/guides/html/migrations.html
  13. +17 −17 railties/doc/guides/html/routing_outside_in.html
  14. +5 −5 railties/doc/guides/html/testing_rails_applications.html
  15. +76 −9 railties/doc/guides/source/finders.txt
  16. 0 railties/doc/guides/source/{ → images}/icons/README
  17. 0 railties/doc/guides/source/{ → images}/icons/callouts/1.png
  18. 0 railties/doc/guides/source/{ → images}/icons/callouts/10.png
  19. 0 railties/doc/guides/source/{ → images}/icons/callouts/11.png
  20. 0 railties/doc/guides/source/{ → images}/icons/callouts/12.png
  21. 0 railties/doc/guides/source/{ → images}/icons/callouts/13.png
  22. 0 railties/doc/guides/source/{ → images}/icons/callouts/14.png
  23. 0 railties/doc/guides/source/{ → images}/icons/callouts/15.png
  24. 0 railties/doc/guides/source/{ → images}/icons/callouts/2.png
  25. 0 railties/doc/guides/source/{ → images}/icons/callouts/3.png
  26. 0 railties/doc/guides/source/{ → images}/icons/callouts/4.png
  27. 0 railties/doc/guides/source/{ → images}/icons/callouts/5.png
  28. 0 railties/doc/guides/source/{ → images}/icons/callouts/6.png
  29. 0 railties/doc/guides/source/{ → images}/icons/callouts/7.png
  30. 0 railties/doc/guides/source/{ → images}/icons/callouts/8.png
  31. 0 railties/doc/guides/source/{ → images}/icons/callouts/9.png
  32. 0 railties/doc/guides/source/{ → images}/icons/caution.png
  33. 0 railties/doc/guides/source/{ → images}/icons/example.png
  34. 0 railties/doc/guides/source/{ → images}/icons/home.png
  35. 0 railties/doc/guides/source/{ → images}/icons/important.png
  36. 0 railties/doc/guides/source/{ → images}/icons/next.png
  37. 0 railties/doc/guides/source/{ → images}/icons/note.png
  38. 0 railties/doc/guides/source/{ → images}/icons/prev.png
  39. 0 railties/doc/guides/source/{ → images}/icons/tip.png
  40. 0 railties/doc/guides/source/{ → images}/icons/up.png
  41. 0 railties/doc/guides/source/{ → images}/icons/warning.png
  42. +1 −1 railties/lib/tasks/documentation.rake
View
3 railties/Rakefile
@@ -282,7 +282,6 @@ task :guides do
FileUtils.mkdir(html)
template = File.expand_path("doc/guides/source/templates/guides.html.erb")
- icons = File.expand_path("doc/guides/source/icons")
ignore = ['icons', 'images', 'templates', 'stylesheets']
ignore << 'active_record_basics.txt'
@@ -303,7 +302,7 @@ task :guides do
begin
puts "GENERATING => #{output}"
ENV['MANUALSONRAILS_TOC'] = 'no' if indexless.include?(entry)
- Mizuho::Generator.new(input, output, template, false, icons).start
+ Mizuho::Generator.new(input, output, template).start
rescue Mizuho::GenerationError
STDERR.puts "*** ERROR"
exit 2
View
10 railties/doc/guides/html/actioncontroller_basics.html
@@ -465,7 +465,7 @@ <h3 id="_accessing_the_session">4.2. Accessing the session</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">There are two <tt>session</tt> methods, the class and the instance method. The class method which is described above is used to turn the session on and off while the instance method described below is used to access session values. The class method is used outside of method definitions while the instance methods is used inside methods, in actions or filters.</td>
</tr></table>
@@ -974,15 +974,15 @@ <h3 id="_sending_files">10.1. Sending files</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/warning.png" alt="Warning" />
+<img src="./images/icons/warning.png" alt="Warning" />
</td>
<td class="content">Be careful when using (or just don't use) "outside" data (params, cookies, etc) to locate the file on disk, as this is a security risk as someone could gain access to files they are not meant to have access to.</td>
</tr></table>
</div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">It is not recommended that you stream static files through Rails if you can instead keep them in a public folder on your web server. It is much more efficient to let the user download the file directly using Apache or another web server, keeping the request from unnecessarily going through the whole Rails stack.</td>
</tr></table>
@@ -1019,7 +1019,7 @@ <h3 id="_restful_downloads">10.2. RESTful downloads</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">Configuration files are not reloaded on each request, so you have to restart the server in order for their changes to take effect.</td>
</tr></table>
@@ -1112,7 +1112,7 @@ <h3 id="_tt_rescue_from_tt">12.2. <tt>rescue_from</tt></h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">Certain exceptions are only rescuable from the ApplicationController class, as they are raised before the controller gets initialized and the action gets executed. See Pratik Naik's <a href="http://m.onkey.org/2008/7/20/rescue-from-dispatching">article</a> on the subject for more information.</td>
</tr></table>
View
32 railties/doc/guides/html/association_basics.html
@@ -433,7 +433,7 @@ <h3 id="_the_tt_has_many_tt_association">2.3. The <tt>has_many</tt> Association<
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">The name of the other model is pluralized when declaring a <tt>has_many</tt> association.</td>
</tr></table>
@@ -573,7 +573,7 @@ <h3 id="_choosing_between_tt_belongs_to_tt_and_tt_has_one_tt">2.7. Choosing Betw
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">Using <tt>t.integer :supplier_id</tt> makes the foreign key naming obvious and implicit. In current versions of Rails, you can abstract away this implementation detail by using <tt>t.references :supplier</tt> instead.</td>
</tr></table>
@@ -777,7 +777,7 @@ <h3 id="_updating_the_schema">3.3. Updating the Schema</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/warning.png" alt="Warning" />
+<img src="./images/icons/warning.png" alt="Warning" />
</td>
<td class="content">The precedence between model names is calculated using the <tt>&lt;</tt> operator for <tt>String</tt>. This means that if the strings are of different lengths, and the strings are equal when compared up to the shortest length, then the longer string is considered of higher lexical precedence than the shorter one. For example, one would expect the tables "paper_boxes" and "papers" to generate a join table name of "papers_paper_boxes" because of the length of the name "paper_boxes", but it in fact generates a join table name of "paper_boxes_papers".</td>
</tr></table>
@@ -1112,7 +1112,7 @@ <h5 id="_tt_dependent_tt"><tt>:dependent</tt></h5>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/warning.png" alt="Warning" />
+<img src="./images/icons/warning.png" alt="Warning" />
</td>
<td class="content">You should not specify this option on a <tt>belongs_to</tt> association that is connected with a <tt>has_many</tt> association on the other class. Doing so can lead to orphaned records in your database.</td>
</tr></table>
@@ -1131,7 +1131,7 @@ <h5 id="_tt_foreign_key_tt"><tt>:foreign_key</tt></h5>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">In any case, Rails will not create foreign key columns for you. You need to explicitly define them as part of your migrations.</td>
</tr></table>
@@ -1174,7 +1174,7 @@ <h5 id="_tt_include_tt"><tt>:include</tt></h5>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">There's no need to use <tt>:include</tt> for immediate associations - that is, if you have <tt>Order belongs_to :customer</tt>, then the customer is eager-loaded automatically when it's needed.</td>
</tr></table>
@@ -1414,7 +1414,7 @@ <h5 id="_tt_foreign_key_tt_2"><tt>:foreign_key</tt></h5>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">In any case, Rails will not create foreign key columns for you. You need to explicitly define them as part of your migrations.</td>
</tr></table>
@@ -1606,7 +1606,7 @@ <h5 id="_tt_em_collection_em_delete_object_8230_tt"><tt><em>collection</em>.dele
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/warning.png" alt="Warning" />
+<img src="./images/icons/warning.png" alt="Warning" />
</td>
<td class="content">Objects will be in addition destroyed if they're associated with <tt>:dependent &#8658; :destroy</tt>, and deleted if they're associated with <tt>:dependent &#8658; :delete_all</tt>.</td>
</tr></table>
@@ -1834,7 +1834,7 @@ <h5 id="_tt_counter_sql_tt"><tt>:counter_sql</tt></h5>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">If you specify <tt>:finder_sql</tt> but not <tt>:counter_sql</tt>, then the counter SQL will be generated by substituting <tt>SELECT COUNT(*) FROM</tt> for the <tt>SELECT &#8230; FROM</tt> clause of your <tt>:finder_sql</tt> statement.</td>
</tr></table>
@@ -1844,7 +1844,7 @@ <h5 id="_tt_dependent_tt_3"><tt>:dependent</tt></h5>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">This option is ignored when you use the <tt>:through</tt> option on the association.</td>
</tr></table>
@@ -1867,7 +1867,7 @@ <h5 id="_tt_foreign_key_tt_3"><tt>:foreign_key</tt></h5>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">In any case, Rails will not create foreign key columns for you. You need to explicitly define them as part of your migrations.</td>
</tr></table>
@@ -1951,7 +1951,7 @@ <h5 id="_tt_select_tt_3"><tt>:select</tt></h5>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/warning.png" alt="Warning" />
+<img src="./images/icons/warning.png" alt="Warning" />
</td>
<td class="content">If you specify your own <tt>:select</tt>, be sure to include the primary key and foreign key columns of the associated model. If you do not, Rails will throw an error.</td>
</tr></table>
@@ -2077,7 +2077,7 @@ <h5 id="_additional_column_methods">Additional Column Methods</h5>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/warning.png" alt="Warning" />
+<img src="./images/icons/warning.png" alt="Warning" />
</td>
<td class="content">The use of extra attributes on the join table in a <tt>has_and_belongs_to_many</tt> association is deprecated. If you require this sort of complex behavior on the table that joins two models in a many-to-many relationship, you should use a <tt>has_many :through</tt> association instead of <tt>has_and_belongs_to_many</tt>.</td>
</tr></table>
@@ -2103,7 +2103,7 @@ <h5 id="_tt_em_collection_em_lt_lt_object_8230_tt_2"><tt><em>collection</em>&lt;
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">This method is aliased as <tt><em>collection</em>.concat</tt> and <tt><em>collection</em>.push</tt>.</td>
</tr></table>
@@ -2296,7 +2296,7 @@ <h5 id="_tt_association_foreign_key_tt"><tt>:association_foreign_key</tt></h5>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">The <tt>:foreign_key</tt> and <tt>:association_foreign_key</tt> options are useful when setting up a many-to-many self-join. For example:</td>
</tr></table>
@@ -2349,7 +2349,7 @@ <h5 id="_tt_counter_sql_tt_2"><tt>:counter_sql</tt></h5>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">If you specify <tt>:finder_sql</tt> but not <tt>:counter_sql</tt>, then the counter SQL will be generated by substituting <tt>SELECT COUNT(*) FROM</tt> for the <tt>SELECT &#8230; FROM</tt> clause of your <tt>:finder_sql</tt> statement.</td>
</tr></table>
View
2 railties/doc/guides/html/benchmarking_and_profiling.html
@@ -578,7 +578,7 @@ <h3 id="_our_first_performance_test">5.1. Our First Performance Test</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">KCachegrind is Linux only. For Mac this means you have to do a full KDE install to have it working in your OS. Which is over 3 gigs in size. For windows there is clone called wincachegrind but it is no longer actively being developed.</td>
</tr></table>
View
4 railties/doc/guides/html/creating_plugins.html
@@ -390,7 +390,7 @@ <h3 id="_create_the_basic_app">1.1. Create the basic app</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">The aforementioned instructions will work for sqlite3. For more detailed instructions on how to create a rails app for other databases see the API docs.</td>
</tr></table>
@@ -438,7 +438,7 @@ <h3 id="_create_the_plugin">1.2. Create the plugin</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">
<div class="title">Editor's note:</div>Many plugin authors prefer to keep this file, and add all of the require statements in it. That way, they only line in init.rb would be <tt>require "yaffle"</tt>. If you are developing a plugin that has a lot of files in the lib directory, you may want to create a subdirectory like lib/yaffle and store your files in there. That way your init.rb file stays clean</td>
View
18 railties/doc/guides/html/debugging_rails_applications.html
@@ -424,7 +424,7 @@ <h3 id="_what_is_the_logger">2.1. What is The Logger?</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">By default, each log is created under <tt>RAILS_ROOT/log/</tt> and the log file name is <tt>environment_name.log</tt>.</td>
</tr></table>
@@ -444,7 +444,7 @@ <h3 id="_log_levels">2.2. Log Levels</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">The default Rails log level is <tt>info</tt> in production mode and <tt>debug</tt> in development and test mode.</td>
</tr></table>
@@ -561,7 +561,7 @@ <h3 id="_setup">3.1. Setup</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">In development mode, you can dynamically <tt>require 'ruby-debug'</tt> instead of restarting the server, if it was started without <tt>&#8212;debugger</tt>.</td>
</tr></table>
@@ -593,7 +593,7 @@ <h3 id="_the_shell">3.2. The Shell</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">To view the help menu for any command use <tt>help &lt;command-name&gt;</tt> in active debug mode. For example: <em><tt>help var</tt></em></td>
</tr></table>
@@ -717,7 +717,7 @@ <h3 id="_inspecting_variables">3.5. Inspecting Variables</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">You can also step into <strong>irb</strong> mode with the command <tt>irb</tt> (of course!). This way an irb session will be started within the context you invoked it. But be warned: this is an experimental feature.</td>
</tr></table>
@@ -748,7 +748,7 @@ <h3 id="_inspecting_variables">3.5. Inspecting Variables</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">The commands <tt>p</tt> (print) and <tt>pp</tt> (pretty print) can be used to evaluate Ruby expressions and display the value of variables to the console.</td>
</tr></table>
@@ -766,7 +766,7 @@ <h3 id="_step_by_step">3.6. Step by Step</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">You can also use <tt>step+ <em>n</em></tt> and <tt>step- <em>n</em></tt> to move forward or backward <em>n</em> steps respectively.</td>
</tr></table>
@@ -796,7 +796,7 @@ <h3 id="_step_by_step">3.6. Step by Step</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">You can use ruby-debug while using script/console. Just remember to <tt>require "ruby-debug"</tt> before calling the <tt>debugger</tt> method.</td>
</tr></table>
@@ -962,7 +962,7 @@ <h3 id="_settings">3.12. Settings</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">You can include any number of these configuration lines inside a <tt>.rdebugrc</tt> file in your HOME directory. ruby-debug will read this file every time it is loaded. and configure itself accordingly.</td>
</tr></table>
View
141 railties/doc/guides/html/finders.html
@@ -258,12 +258,17 @@ <h2 id="site_title_tagline">Sustainable productivity for web-application develop
<li><a href="#_count">Count</a></li>
+ <li><a href="#_average">Average</a></li>
+
+ <li><a href="#_minimum">Minimum</a></li>
+
+ <li><a href="#_maximum">Maximum</a></li>
+
+ <li><a href="#_sum">Sum</a></li>
+
</ul>
</li>
<li>
- <a href="#_with_scope">With Scope</a>
- </li>
- <li>
<a href="#_credits">Credits</a>
</li>
<li>
@@ -282,6 +287,8 @@ <h2 id="site_title_tagline">Sustainable productivity for web-application develop
<li><a href="#_tuesday_21_october_2008">Tuesday, 21 October 2008</a></li>
+ <li><a href="#_wednesday_22_october_2008">Wednesday, 22 October 2008</a></li>
+
</ul>
</li>
</ol>
@@ -550,7 +557,23 @@ <h2 id="_limit_amp_offset">8. Limit &amp; Offset</h2>
</div>
<h2 id="_group">9. Group</h2>
<div class="sectionbody">
-<div class="para"><p>TODO</p></div>
+<div class="para"><p>The group option for find is useful, for example, if you want to find a collection of the dates orders were created on. We could use the option in this context:</p></div>
+<div class="exampleblock">
+<div class="exampleblock-content"><!-- Generator: GNU source-highlight 2.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>Order<span style="color: #990000">.</span>find<span style="color: #990000">(:</span>all<span style="color: #990000">,</span> <span style="color: #990000">:</span>group <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">"date(created_at)"</span><span style="color: #990000">,</span> <span style="color: #990000">:</span>order <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">"created_at"</span><span style="color: #990000">)</span>
+</tt></pre></div></div>
+<div class="para"><p>And this will give us a single Order object for each date that we have orders in our database.</p></div>
+<div class="para"><p>The SQL that would be executed would be something like this:</p></div>
+<div class="exampleblock">
+<div class="exampleblock-content"><!-- Generator: GNU source-highlight 2.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">SELECT</span></span> <span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #0000FF">FROM</span></span> <span style="color: #FF0000">`orders`</span> <span style="font-weight: bold"><span style="color: #0000FF">GROUP</span></span> <span style="font-weight: bold"><span style="color: #0000FF">BY</span></span> <span style="color: #009900">date</span><span style="color: #990000">(</span>created_at<span style="color: #990000">)</span>
+</tt></pre></div></div>
</div>
<h2 id="_read_only">10. Read Only</h2>
<div class="sectionbody">
@@ -577,7 +600,15 @@ <h2 id="_lock">11. Lock</h2>
<div class="sectionbody">
<div class="para"><p>If you're wanting to stop race conditions for a specific record, say for example you're incrementing a single field for a record you can use the lock option to ensure that the record is updated correctly. It's recommended this be used inside a transaction.</p></div>
<div class="exampleblock">
-<div class="exampleblock-content"></div></div>
+<div class="exampleblock-content"><!-- Generator: GNU source-highlight 2.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>Topic<span style="color: #990000">.</span>transaction <span style="font-weight: bold"><span style="color: #0000FF">do</span></span>
+ t <span style="color: #990000">=</span> Topic<span style="color: #990000">.</span>find<span style="color: #990000">(</span>params<span style="color: #990000">[:</span>id<span style="color: #990000">],</span> <span style="color: #990000">:</span>lock <span style="color: #990000">=&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span><span style="color: #990000">)</span>
+ t<span style="color: #990000">.</span>increment!<span style="color: #990000">(:</span>views<span style="color: #990000">)</span>
+<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
+</tt></pre></div></div>
</div>
<h2 id="_making_it_all_work_together">12. Making It All Work Together</h2>
<div class="sectionbody">
@@ -607,7 +638,12 @@ <h2 id="_eager_loading">13. Eager Loading</h2>
<div class="para"><p>This query is more efficent, but there's a gotcha. If you have a client who does not have an address or a mailing address they will not be returned in this query at all. If you have any association as an optional association, you may want to use include rather than joins.</p></div>
<div class="para"><p>When using eager loading you can specify conditions for the columns of the tables inside the eager loading to get back a smaller subset. If, for example, you want to find a client and all their orders within the last two weeks you could use eager loading with conditions for this:</p></div>
<div class="exampleblock">
-<div class="exampleblock-content"></div></div>
+<div class="exampleblock-content"><!-- Generator: GNU source-highlight 2.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>Client<span style="color: #990000">.</span>find<span style="color: #990000">(:</span>first<span style="color: #990000">,</span> <span style="color: #990000">:</span><span style="font-weight: bold"><span style="color: #0000FF">include</span></span> <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">"orders"</span><span style="color: #990000">,</span> <span style="color: #990000">:</span>conditions <span style="color: #990000">=&gt;</span> <span style="color: #990000">[</span><span style="color: #FF0000">"orders.created_at &gt;= ? AND orders.created_at &lt;= ?"</span><span style="color: #990000">,</span> Time<span style="color: #990000">.</span>now <span style="color: #990000">-</span> <span style="color: #993399">2</span><span style="color: #990000">.</span>weeks<span style="color: #990000">,</span> Time<span style="color: #990000">.</span>now<span style="color: #990000">])</span>
+</tt></pre></div></div>
</div>
<h2 id="_dynamic_finders">14. Dynamic finders</h2>
<div class="sectionbody">
@@ -776,8 +812,7 @@ <h2 id="_existance_of_objects">18. Existance of Objects</h2>
</div>
<h2 id="_calculations">19. Calculations</h2>
<div class="sectionbody">
-<h3 id="_count">19.1. Count</h3>
-<div class="para"><p>If you want to see how many records are in your models table you could call <tt>Client.count</tt> and that will return the number. If you want to be more specific and find all the clients with their age present in the database you can use <tt>Client.count(:age)</tt>.</p></div>
+<div class="para"><p>This section uses count as an example method in this preamble, but the options described apply to all sub-sections.</p></div>
<div class="para"><p><tt>count</tt> takes conditions much in the same way <tt>exists?</tt> does:</p></div>
<div class="exampleblock">
<div class="exampleblock-content"><!-- Generator: GNU source-highlight 2.9
@@ -786,26 +821,84 @@ <h3 id="_count">19.1. Count</h3>
http://www.gnu.org/software/src-highlite -->
<pre><tt>Client<span style="color: #990000">.</span>count<span style="color: #990000">(:</span>conditions <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">"first_name = 'Ryan'"</span><span style="color: #990000">)</span>
</tt></pre></div></div>
+<div class="para"><p>Which will execute:</p></div>
<div class="exampleblock">
<div class="exampleblock-content"><!-- Generator: GNU source-highlight 2.9
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">SELECT</span></span> count<span style="color: #990000">(*)</span> <span style="font-weight: bold"><span style="color: #0000FF">AS</span></span> count_all <span style="font-weight: bold"><span style="color: #0000FF">FROM</span></span> <span style="color: #FF0000">`clients`</span> <span style="font-weight: bold"><span style="color: #0000FF">WHERE</span></span> <span style="color: #990000">(</span>first_name <span style="color: #990000">=</span> <span style="color: #993399">1</span><span style="color: #990000">)</span>
</tt></pre></div></div>
+<div class="para"><p>You can also use <tt>include</tt> or <tt>joins</tt> for this to do something a little more complex:</p></div>
+<div class="exampleblock">
+<div class="exampleblock-content"><!-- Generator: GNU source-highlight 2.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>Client<span style="color: #990000">.</span>count<span style="color: #990000">(:</span>conditions <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">"clients.first_name = 'Ryan' AND orders.status = 'received'"</span><span style="color: #990000">,</span> <span style="color: #990000">:</span><span style="font-weight: bold"><span style="color: #0000FF">include</span></span> <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">"orders"</span><span style="color: #990000">)</span>
+</tt></pre></div></div>
+<div class="para"><p>Which will execute:</p></div>
+<div class="exampleblock">
+<div class="exampleblock-content"><!-- Generator: GNU source-highlight 2.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">SELECT</span></span> count<span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">DISTINCT</span></span> <span style="color: #FF0000">`clients`</span><span style="color: #990000">.</span>id<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">AS</span></span> count_all <span style="font-weight: bold"><span style="color: #0000FF">FROM</span></span> <span style="color: #FF0000">`clients`</span> <span style="font-weight: bold"><span style="color: #0000FF">LEFT</span></span> <span style="font-weight: bold"><span style="color: #0000FF">OUTER</span></span> <span style="font-weight: bold"><span style="color: #0000FF">JOIN</span></span> <span style="color: #FF0000">`orders`</span> <span style="font-weight: bold"><span style="color: #0000FF">ON</span></span> orders<span style="color: #990000">.</span>client_id <span style="color: #990000">=</span> client<span style="color: #990000">.</span>id <span style="font-weight: bold"><span style="color: #0000FF">WHERE</span></span> <span style="color: #990000">(</span>clients<span style="color: #990000">.</span>first_name <span style="color: #990000">=</span> <span style="color: #FF0000">'name'</span> <span style="font-weight: bold"><span style="color: #0000FF">AND</span></span> orders<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #0000FF">status</span></span> <span style="color: #990000">=</span> <span style="color: #FF0000">'received'</span><span style="color: #990000">)</span>
+</tt></pre></div></div>
+<div class="para"><p>We specify <tt>clients.first_name</tt> just in case one of our join tables has a field also called <tt>first_name</tt> and we do <tt>orders.status</tt> because that's the name of our join table.</p></div>
+<h3 id="_count">19.1. Count</h3>
+<div class="para"><p>If you want to see how many records are in your model's table you could call <tt>Client.count</tt> and that will return the number. If you want to be more specific and find all the clients with their age present in the database you can use <tt>Client.count(:age)</tt>.</p></div>
+<div class="para"><p>For options, please see the parent section, Calculations.</p></div>
+<h3 id="_average">19.2. Average</h3>
+<div class="para"><p>If you want to see the average of a certain number in one of your tables you can call the <tt>average</tt> method on the class that relates to the table. This method call will look something like this:</p></div>
+<div class="exampleblock">
+<div class="exampleblock-content"><!-- Generator: GNU source-highlight 2.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>Client<span style="color: #990000">.</span>average<span style="color: #990000">(</span><span style="color: #FF0000">"orders_count"</span><span style="color: #990000">)</span>
+</tt></pre></div></div>
+<div class="para"><p>This will return a number (possibly a floating point number such as 3.14159265) representing the average of the fields.</p></div>
+<div class="para"><p>For options, please see the parent section, <a href="#_calculations">Calculations</a></p></div>
+<h3 id="_minimum">19.3. Minimum</h3>
+<div class="para"><p>If you want to find the minimum value of a field in your table you can call the <tt>minimum</tt> method on the class that relates to the table. This method call will look something like this:</p></div>
+<div class="exampleblock">
+<div class="exampleblock-content"><!-- Generator: GNU source-highlight 2.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>Client<span style="color: #990000">.</span>minimum<span style="color: #990000">(</span><span style="color: #FF0000">"age"</span><span style="color: #990000">)</span>
+</tt></pre></div></div>
+<div class="para"><p>For options, please see the parent section, <a href="#_calculations">Calculations</a></p></div>
+<h3 id="_maximum">19.4. Maximum</h3>
+<div class="para"><p>If you want to find the maximum value of a field in your table you can call the <tt>maximum</tt> method on the class that relates to the table. This method call will look something like this:</p></div>
+<div class="exampleblock">
+<div class="exampleblock-content"><!-- Generator: GNU source-highlight 2.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>Client<span style="color: #990000">.</span>maximum<span style="color: #990000">(</span><span style="color: #FF0000">"age"</span><span style="color: #990000">)</span>
+</tt></pre></div></div>
+<div class="para"><p>For options, please see the parent section, <a href="#_calculations">Calculations</a></p></div>
+<h3 id="_sum">19.5. Sum</h3>
+<div class="para"><p>If you want to find the sum of a field for all records in your table you can call the <tt>sum</tt> method on the class that relates to the table. This method call will look something like this:</p></div>
+<div class="exampleblock">
+<div class="exampleblock-content"><!-- Generator: GNU source-highlight 2.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt>Client<span style="color: #990000">.</span>sum<span style="color: #990000">(</span><span style="color: #FF0000">"orders_count"</span><span style="color: #990000">)</span>
+</tt></pre></div></div>
+<div class="para"><p>For options, please see the parent section, <a href="#_calculations">Calculations</a></p></div>
</div>
-<h2 id="_with_scope">20. With Scope</h2>
-<div class="sectionbody">
-<div class="para"><p>TODO</p></div>
-</div>
-<h2 id="_credits">21. Credits</h2>
+<h2 id="_credits">20. Credits</h2>
<div class="sectionbody">
<div class="para"><p>Thanks to Ryan Bates for his awesome screencast on named scope #108. The information within the named scope section is intentionally similar to it, and without the cast may have not been possible.</p></div>
<div class="para"><p>Thanks to Mike Gunderloy for his tips on creating this guide.</p></div>
</div>
-<h2 id="_change_log">22. Change Log</h2>
+<h2 id="_change_log">21. Change Log</h2>
<div class="sectionbody">
-<h3 id="_sunday_28_september_2008">22.1. Sunday, 28 September 2008</h3>
+<h3 id="_sunday_28_september_2008">21.1. Sunday, 28 September 2008</h3>
<div class="olist"><ol>
<li>
<p>
@@ -833,7 +926,7 @@ <h3 id="_sunday_28_september_2008">22.1. Sunday, 28 September 2008</h3>
</p>
</li>
</ol></div>
-<h3 id="_wednesday_01_october_2008">22.2. Wednesday, 01 October 2008</h3>
+<h3 id="_wednesday_01_october_2008">21.2. Wednesday, 01 October 2008</h3>
<div class="olist"><ol>
<li>
<p>
@@ -846,7 +939,7 @@ <h3 id="_wednesday_01_october_2008">22.2. Wednesday, 01 October 2008</h3>
</p>
</li>
</ol></div>
-<h3 id="_sunday_05_october_2008">22.3. Sunday, 05 October 2008</h3>
+<h3 id="_sunday_05_october_2008">21.3. Sunday, 05 October 2008</h3>
<div class="olist"><ol>
<li>
<p>
@@ -864,15 +957,15 @@ <h3 id="_sunday_05_october_2008">22.3. Sunday, 05 October 2008</h3>
</p>
</li>
</ol></div>
-<h3 id="_monday_06_october_2008">22.4. Monday, 06 October 2008</h3>
+<h3 id="_monday_06_october_2008">21.4. Monday, 06 October 2008</h3>
<div class="olist"><ol>
<li>
<p>
Added section in Eager Loading about using conditions on tables that are not the model's own.
</p>
</li>
</ol></div>
-<h3 id="_thursday_09_october_2008">22.5. Thursday, 09 October 2008</h3>
+<h3 id="_thursday_09_october_2008">21.5. Thursday, 09 October 2008</h3>
<div class="olist"><ol>
<li>
<p>
@@ -885,14 +978,22 @@ <h3 id="_thursday_09_october_2008">22.5. Thursday, 09 October 2008</h3>
</p>
</li>
</ol></div>
-<h3 id="_tuesday_21_october_2008">22.6. Tuesday, 21 October 2008</h3>
+<h3 id="_tuesday_21_october_2008">21.6. Tuesday, 21 October 2008</h3>
<div class="olist"><ol>
<li>
<p>
Extended named scope guide by adding :include and :joins and find sub-sections.
</p>
</li>
</ol></div>
+<h3 id="_wednesday_22_october_2008">21.7. Wednesday, 22 October 2008</h3>
+<div class="olist"><ol>
+<li>
+<p>
+Completed calculations section.
+</p>
+</li>
+</ol></div>
</div>
</div>
View
18 railties/doc/guides/html/form_helpers.html
@@ -259,7 +259,7 @@ <h2 id="site_title_tagline">Sustainable productivity for web-application develop
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">This guide is not intended to be a complete documentation of available form helpers and their arguments. Please visit <a href="http://api.rubyonrails.org/">the Rails API documentation</a> for a complete reference.</td>
</tr></table>
@@ -290,7 +290,7 @@ <h2 id="_basic_forms">1. Basic forms</h2>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">Throughout this guide, this <tt>div</tt> with the hidden input will be stripped away to have clearer code samples.</td>
</tr></table>
@@ -322,7 +322,7 @@ <h3 id="_generic_search_form">1.1. Generic search form</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/important.png" alt="Important" />
+<img src="./images/icons/important.png" alt="Important" />
</td>
<td class="content">Always use "GET" as the method for search forms. Benefits are many: users are able to bookmark a specific search and get back to it; browsers cache results of "GET" requests, but not "POST"; and other.</td>
</tr></table>
@@ -340,7 +340,7 @@ <h3 id="_generic_search_form">1.1. Generic search form</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">
<div class="para"><p><tt>search_path</tt> can be a named route specified in "routes.rb":</p></div>
@@ -365,7 +365,7 @@ <h3 id="_generic_search_form">1.1. Generic search form</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">For every form input, an ID attribute is generated from its name ("q" in our example). These IDs can be very useful for CSS styling or manipulation of form controls with JavaScript.</td>
</tr></table>
@@ -390,7 +390,7 @@ <h3 id="_multiple_hashes_in_form_helper_attributes">1.2. Multiple hashes in form
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/warning.png" alt="Warning" />
+<img src="./images/icons/warning.png" alt="Warning" />
</td>
<td class="content">Do not delimit the second hash without doing so with the first hash, otherwise your method invocation will result in an ugly <tt>expecting tASSOC</tt> syntax error.</td>
</tr></table>
@@ -429,7 +429,7 @@ <h3 id="_checkboxes_radio_buttons_and_other_controls">1.3. Checkboxes, radio but
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/important.png" alt="Important" />
+<img src="./images/icons/important.png" alt="Important" />
</td>
<td class="content">Always use labels for each checkbox and radio button. They associate text with a specific option, while also providing a larger clickable region.</td>
</tr></table>
@@ -451,7 +451,7 @@ <h3 id="_checkboxes_radio_buttons_and_other_controls">1.3. Checkboxes, radio but
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">If you're using password input fields (for any purpose), you might want to prevent their values showing up in application logs by activating <tt>filter_parameter_logging(:password)</tt> in your ApplicationController.</td>
</tr></table>
@@ -557,7 +557,7 @@ <h3 id="_relying_on_record_identification">2.1. Relying on record identification
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/warning.png" alt="Warning" />
+<img src="./images/icons/warning.png" alt="Warning" />
</td>
<td class="content">When you're using STI (single-table inheritance) with your models, you can't rely on record identification on a subclass if only their parent class is declared a resource. You will have to specify the model name, <tt>:url</tt> and <tt>:method</tt> explicitly.</td>
</tr></table>
View
28 railties/doc/guides/html/getting_started_with_rails.html
@@ -496,7 +496,7 @@ <h3 id="_installing_rails">3.1. Installing Rails</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">There are some special circumstances in which you might want to use an alternate installation strategy:</td>
</tr></table>
@@ -750,7 +750,7 @@ <h2 id="_hello_rails">4. Hello, Rails!</h2>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">If you're on Windows, or your Ruby is set up in some non-standard fashion, you may need to explicitly pass Rails <tt>script</tt> commands to Ruby: <tt>ruby script/generate controller home index</tt>.</td>
</tr></table>
@@ -779,7 +779,7 @@ <h3 id="_starting_up_the_web_server">4.1. Starting up the Web Server</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">To stop the web server, hit Ctrl+C in the terminal window where it's running. In development mode, Rails does not generally require you to stop the server; changes you make in files will be automatically picked up by the server.</td>
</tr></table>
@@ -817,7 +817,7 @@ <h3 id="_setting_the_application_home_page">4.2. Setting the Application Home Pa
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">For more information about routing, refer to <a href="../routing_outside_in.html">Rails Routing from the Outside In</a>.</td>
</tr></table>
@@ -840,7 +840,7 @@ <h2 id="_creating_a_resource">6. Creating a Resource</h2>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">While scaffolding will get you up and running quickly, the "one size fits all" code that it generates is unlikely to be a perfect fit for your application. In most cases, you'll need to customize the generated code. Many experienced Rails developers avoid scaffolding entirely, preferring to write all or most of their source code from scratch.</td>
</tr></table>
@@ -1015,7 +1015,7 @@ <h3 id="_running_a_migration">6.1. Running a Migration</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">Because you're working in the development environment by default, both of these commands will apply to the database defined in the <tt>development</tt> section of your <tt>config/database.yml</tt> file.</td>
</tr></table>
@@ -1041,7 +1041,7 @@ <h3 id="_working_with_posts_in_the_browser">6.3. Working with Posts in the Brows
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">In development mode (which is what you're working in by default), Rails reloads your application with every browser request, so there's no need to stop and restart the web server.</td>
</tr></table>
@@ -1101,7 +1101,7 @@ <h3 id="_using_the_console">6.6. Using the Console</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">Unlike the development web server, the console does not automatically load your code afresh for each line. If you make changes, type <tt>reload!</tt> at the console prompt to load them.</td>
</tr></table>
@@ -1126,7 +1126,7 @@ <h3 id="_listing_all_posts">6.7. Listing All Posts</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">For more information on finding records with Active Record, see <a href="../finders.html">Active Record Finders</a>.</td>
</tr></table>
@@ -1183,7 +1183,7 @@ <h3 id="_listing_all_posts">6.7. Listing All Posts</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">For more details on the rendering process, see <a href="../layouts_and_rendering.html">Layouts and Rendering in Rails</a>.</td>
</tr></table>
@@ -1264,7 +1264,7 @@ <h3 id="_creating_new_posts">6.9. Creating New Posts</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">If you need to create an HTML form that displays arbitrary fields, not tied to a model, you should use the <tt>form_tag</tt> method, which provides shortcuts for building forms that are not necessarily tied to a model instance.</td>
</tr></table>
@@ -1400,7 +1400,7 @@ <h3 id="_editing_posts">6.11. Editing Posts</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">Sharp-eyed readers will have noticed that the <tt>form_for</tt> declaration is identical for the <tt>create</tt> and <tt>edit</tt> views. Rails generates different code for the two forms because it's smart enough to notice that in the one case it's being passed a new record that has never been saved, and in the other case an existing record that has already been saved to the database. In a production Rails application, you would ordinarily eliminate this duplication by moving identical code to a <em>partial template</em>, which you could then include in both parent templates. But the scaffold generator tries not to make too many assumptions, and generates code that’s easy to modify if you want different forms for <tt>create</tt> and <tt>edit</tt>.</td>
</tr></table>
@@ -1536,7 +1536,7 @@ <h3 id="_associating_models">7.2. Associating Models</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">For more information on Active Record associations, see the <a href="../association_basics.html+">Active Record Associations</a> guide.</td>
</tr></table>
@@ -1556,7 +1556,7 @@ <h3 id="_adding_a_route">7.3. Adding a Route</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">For more information on routing, see the <a href="../routing_outside_in">Rails Routing from the Outside In</a> guide.</td>
</tr></table>
View
22 railties/doc/guides/html/index.html
@@ -202,15 +202,15 @@ <h2 id="site_title_tagline">Sustainable productivity for web-application develop
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/warning.png" alt="Warning" />
+<img src="./images/icons/warning.png" alt="Warning" />
</td>
<td class="content">This page is the result of ongoing <a href="http://hackfest.rubyonrails.org/guide">Rails Guides hackfest</a> and a work in progress.</td>
</tr></table>
</div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/caution.png" alt="Caution" />
+<img src="./images/icons/caution.png" alt="Caution" />
</td>
<td class="content">Guides marked with this icon are currently being worked on. While they might still be useful to you, they may contain incomplete information and even errors. You can help by reviewing them and posting your comments and corrections at the respective Lighthouse ticket.</td>
</tr></table>
@@ -222,7 +222,7 @@ <h2 id="site_title_tagline">Sustainable productivity for web-application develop
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/caution.png" alt="Caution" />
+<img src="./images/icons/caution.png" alt="Caution" />
</td>
<td class="content"><a href="http://rails.lighthouseapp.com/projects/16213/tickets/2">Lighthouse Ticket</a></td>
</tr></table>
@@ -246,7 +246,7 @@ <h2 id="site_title_tagline">Sustainable productivity for web-application develop
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/caution.png" alt="Caution" />
+<img src="./images/icons/caution.png" alt="Caution" />
</td>
<td class="content"><a href="http://rails.lighthouseapp.com/projects/16213/tickets/16">Lighthouse Ticket</a></td>
</tr></table>
@@ -267,7 +267,7 @@ <h2 id="site_title_tagline">Sustainable productivity for web-application develop
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/caution.png" alt="Caution" />
+<img src="./images/icons/caution.png" alt="Caution" />
</td>
<td class="content"><a href="http://rails.lighthouseapp.com/projects/16213/tickets/1">Lighthouse Ticket</a></td>
</tr></table>
@@ -287,7 +287,7 @@ <h2 id="site_title_tagline">Sustainable productivity for web-application develop
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/caution.png" alt="Caution" />
+<img src="./images/icons/caution.png" alt="Caution" />
</td>
<td class="content"><a href="http://rails.lighthouseapp.com/projects/16213/tickets/17">Lighthouse Ticket</a></td>
</tr></table>
@@ -300,7 +300,7 @@ <h2 id="site_title_tagline">Sustainable productivity for web-application develop
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/caution.png" alt="Caution" />
+<img src="./images/icons/caution.png" alt="Caution" />
</td>
<td class="content"><a href="http://rails.lighthouseapp.com/projects/16213/tickets/10">Lighthouse Ticket</a></td>
</tr></table>
@@ -314,7 +314,7 @@ <h2 id="site_title_tagline">Sustainable productivity for web-application develop
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/caution.png" alt="Caution" />
+<img src="./images/icons/caution.png" alt="Caution" />
</td>
<td class="content"><a href="http://rails.lighthouseapp.com/projects/16213/tickets/8">Lighthouse Ticket</a></td>
</tr></table>
@@ -329,7 +329,7 @@ <h2 id="site_title_tagline">Sustainable productivity for web-application develop
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/caution.png" alt="Caution" />
+<img src="./images/icons/caution.png" alt="Caution" />
</td>
<td class="content"><a href="http://rails.lighthouseapp.com/projects/16213/tickets/7">Lighthouse Ticket</a></td>
</tr></table>
@@ -343,7 +343,7 @@ <h2 id="site_title_tagline">Sustainable productivity for web-application develop
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/caution.png" alt="Caution" />
+<img src="./images/icons/caution.png" alt="Caution" />
</td>
<td class="content"><a href="http://rails.lighthouseapp.com/projects/16213/tickets/5">Lighthouse Ticket</a></td>
</tr></table>
@@ -358,7 +358,7 @@ <h2 id="site_title_tagline">Sustainable productivity for web-application develop
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/caution.png" alt="Caution" />
+<img src="./images/icons/caution.png" alt="Caution" />
</td>
<td class="content"><a href="http://rails.lighthouseapp.com/projects/16213/tickets/4">Lighthouse Ticket</a></td>
</tr></table>
View
26 railties/doc/guides/html/layouts_and_rendering.html
@@ -300,7 +300,7 @@ <h3 id="_rendering_by_default_convention_over_configuration_in_action">2.1. Rend
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">The actual rendering is done by subclasses of <tt>ActionView::TemplateHandlers</tt>. This guide does not dig into that process, but it's important to know that the file extension on your view controls the choice of template handler. In Rails 2, the standard extensions are <tt>.erb</tt> for ERB (HTML with embedded Ruby), <tt>.rjs</tt> for RJS (javascript with embedded ruby) and <tt>.builder</tt> for Builder (XML generator). You'll also find <tt>.rhtml</tt> used for ERB templates and .rxml for Builder templates, but those extensions are now formally deprecated and will be removed from a future version of Rails.</td>
</tr></table>
@@ -310,7 +310,7 @@ <h3 id="_using_tt_render_tt">2.2. Using <tt>render</tt></h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">If you want to see the exact results of a call to <tt>render</tt> without needing to inspect it in a browser, you can call <tt>render_to_string</tt>. This method takes exactly the same options as <tt>render</tt>, but it returns a string instead of sending a response back to the browser.</td>
</tr></table>
@@ -328,7 +328,7 @@ <h4 id="_rendering_nothing">2.2.1. Rendering Nothing</h4>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">You should probably be using the <tt>head</tt> method, discussed later in this guide, instead of <tt>render :nothing</tt>. This provides additional flexibility and makes it explicit that you're only generating HTTP headers.</td>
</tr></table>
@@ -354,7 +354,7 @@ <h4 id="_using_tt_render_tt_with_tt_action_tt">2.2.2. Using <tt>render</tt> with
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/warning.png" alt="Warning" />
+<img src="./images/icons/warning.png" alt="Warning" />
</td>
<td class="content">Using <tt>render</tt> with <tt>:action</tt> is a frequent source of confusion for Rails newcomers. The specified action is used to determine which view to render, but Rails does <em>not</em> run any of the code for that action in the controller. Any instance variables that you require in the view must be set up in the current action before calling <tt>render</tt>.</td>
</tr></table>
@@ -381,7 +381,7 @@ <h4 id="_using_tt_render_tt_with_tt_file_tt">2.2.4. Using <tt>render</tt> with <
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">By default, if you use the <tt>:file</tt> option, the file is rendered without using the current layout. If you want Rails to put the file into the current layout, you need to add the <tt>:layout &#8658; true</tt> option</td>
</tr></table>
@@ -398,7 +398,7 @@ <h4 id="_using_tt_render_tt_with_tt_inline_tt">2.2.5. Using <tt>render</tt> with
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/warning.png" alt="Warning" />
+<img src="./images/icons/warning.png" alt="Warning" />
</td>
<td class="content">There is seldom any good reason to use this option. Mixing ERB into your controllers defeats the MVC orientation of Rails and will make it harder for other developers to follow the logic of your project. Use a separate erb view instead.</td>
</tr></table>
@@ -425,7 +425,7 @@ <h4 id="_using_tt_render_tt_with_tt_update_tt">2.2.6. Using <tt>render</tt> with
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/warning.png" alt="Warning" />
+<img src="./images/icons/warning.png" alt="Warning" />
</td>
<td class="content">Placing javascript updates in your controller may seem to streamline small updates, but it defeats the MVC orientation of Rails and will make it harder for other developers to follow the logic of your project. I recommend using a separate rjs template instead, no matter how small the update.</td>
</tr></table>
@@ -442,15 +442,15 @@ <h4 id="_rendering_text">2.2.7. Rendering Text</h4>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">Rendering pure text is most useful when you're responding to AJAX or web service requests that are expecting something other than proper HTML.</td>
</tr></table>
</div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">By default, if you use the <tt>:text</tt> option, the file is rendered without using the current layout. If you want Rails to put the text into the current layout, you need to add the <tt>:layout &#8658; true</tt> option</td>
</tr></table>
@@ -467,7 +467,7 @@ <h4 id="_rendering_json">2.2.8. Rendering JSON</h4>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">You don't need to call <tt>to_json</tt> on the object that you want to render. If you use the <tt>:json</tt> option, <tt>render</tt> will automatically call <tt>to_json</tt> for you.</td>
</tr></table>
@@ -484,7 +484,7 @@ <h4 id="_rendering_xml">2.2.9. Rendering XML</h4>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">You don't need to call <tt>to_xml</tt> on the object that you want to render. If you use the <tt>:xml</tt> option, <tt>render</tt> will automatically call <tt>to_xml</tt> for you.</td>
</tr></table>
@@ -714,7 +714,7 @@ <h3 id="_asset_tags">3.1. Asset Tags</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/warning.png" alt="Warning" />
+<img src="./images/icons/warning.png" alt="Warning" />
</td>
<td class="content">The asset tags do <em>not</em> verify the existence of the assets at the specified locations; they simply assume that you know what you're doing and generate the link.</td>
</tr></table>
@@ -1036,7 +1036,7 @@ <h4 id="_using_partials_to_simplify_views">3.4.2. Using Partials to Simplify Vie
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">For content that is shared among all pages in your application, you can use partials directly from layouts.</td>
</tr></table>
View
6 railties/doc/guides/html/migrations.html
@@ -354,7 +354,7 @@ <h2 id="_anatomy_of_a_migration">1. Anatomy Of A Migration</h2>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">Some <a href="#models">caveats</a> apply to using models in your migrations.</td>
</tr></table>
@@ -657,7 +657,7 @@ <h3 id="_special_helpers">3.3. Special helpers</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">The <tt>references</tt> helper does not actually create foreign key constraints for you. You will need to use <tt>execute</tt> for that or a plugin that adds <a href="#foreign_key">foreign key support</a>.</td>
</tr></table>
@@ -728,7 +728,7 @@ <h3 id="_rolling_back">4.1. Rolling back</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">This is not the same as running all the migrations - see the section on <a href="#schema">schema.rb</a>.</td>
</tr></table>
View
34 railties/doc/guides/html/routing_outside_in.html
@@ -372,7 +372,7 @@ <h3 id="_generating_urls_from_code">1.2. Generating URLs from Code</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">Patient needs to be declared as a resource for this style of translation via a named route to be available.</td>
</tr></table>
@@ -647,7 +647,7 @@ <h3 id="_crud_verbs_and_actions">3.2. CRUD, Verbs, and Actions</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">If you consistently use RESTful routes in your application, you should disable the default routes in <tt>routes.rb</tt> so that Rails will enforce the mapping between HTTP verbs and routes.</td>
</tr></table>
@@ -679,7 +679,7 @@ <h3 id="_urls_and_paths">3.3. URLs and Paths</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">Because routing makes use of the HTTP verb as well as the path in the request to dispatch requests, the seven routes generated by a RESTful routing entry only give rise to four pairs of helpers.</td>
</tr></table>
@@ -859,7 +859,7 @@ <h3 id="_singular_resources">3.5. Singular Resources</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">Even though the name of the resource is singular in <tt>routes.rb</tt>, the matching controller is still plural.</td>
</tr></table>
@@ -1091,7 +1091,7 @@ <h4 id="_using_controller">3.6.1. Using :controller</h4>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">The helpers will be generated with the name of the resource, not the name of the controller. So in this case, you'd still get <tt>photos_path</tt>, <tt>new_photo_path</tt>, and so on.</td>
</tr></table>
@@ -1109,7 +1109,7 @@ <h3 id="_controller_namespaces_and_routing">3.7. Controller Namespaces and Routi
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">If you want to guarantee that a link goes to a top-level controller, use a preceding slash to anchor the controller name: <tt>&lt;%= link_to "show", {:controller &#8658; "/photos", :action &#8658; "show"} %&gt;</tt></td>
</tr></table>
@@ -1145,7 +1145,7 @@ <h4 id="_using_singular">3.7.1. Using :singular</h4>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">Depending on the other code in your application, you may prefer to add additional rules to the <tt>Inflector</tt> class instead.</td>
</tr></table>
@@ -1326,7 +1326,7 @@ <h4 id="_using_as">3.7.4. Using :as</h4>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">The helpers will be generated with the name of the resource, not the path name. So in this case, you'd still get <tt>photos_path</tt>, <tt>new_photo_path</tt>, and so on.</td>
</tr></table>
@@ -1349,15 +1349,15 @@ <h4 id="_using_path_names">3.7.5. Using :path_names</h4>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">The actual action names aren't changed by this option; the two URLs show would still route to the new and edit actions.</td>
</tr></table>
</div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">If you find yourself wanting to change this option uniformly for all of your routes, you can set a default in your environment:</td>
</tr></table>
@@ -1387,15 +1387,15 @@ <h4 id="_using_path_prefix">3.7.6. Using :path_prefix</h4>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">In most cases, it's simpler to recognize URLs of this sort by creating nested resources, as discussed in the next section.</td>
</tr></table>
</div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">You can also use <tt>:path_prefix</tt> with non-RESTful routes.</td>
</tr></table>
@@ -1414,7 +1414,7 @@ <h4 id="_using_name_prefix">3.7.7. Using :name_prefix</h4>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">You can also use <tt>:name_prefix</tt> with non-RESTful routes.</td>
</tr></table>
@@ -1808,7 +1808,7 @@ <h4 id="_adding_new_routes">3.11.3. Adding New Routes</h4>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">If you want to redefine the verbs accepted by one of the standard actions, you can do so by explicitly mapping that action. For example:</td>
</tr></table>
@@ -2001,7 +2001,7 @@ <h2 id="_the_default_routes">6. The Default Routes</h2>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">The default routes will make every action of every controller in your application accessible to GET requests. If you've designed your application to make consistent use of RESTful and named routes, you should comment out the default routes to prevent access to your controllers through the wrong verbs. If you've had the default routes enabled during development, though, you need to be sure that you haven't unwittingly depended on them somewhere in your application - otherwise you may find mysterious failures when you disable them.</td>
</tr></table>
@@ -2042,7 +2042,7 @@ <h3 id="_connecting_the_empty_string">7.2. Connecting the Empty String</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">If the empty route does not seem to be working in your application, make sure that you have deleted the file <tt>public/index.html</tt> from your Rails tree.</td>
</tr></table>
@@ -2086,7 +2086,7 @@ <h3 id="_seeing_existing_routes_with_rake">8.1. Seeing Existing Routes with rake
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">You'll find that the output from <tt>rake routes</tt> is much more readable if you widen your terminal window until the output lines don't wrap.</td>
</tr></table>
View
10 railties/doc/guides/html/testing_rails_applications.html
@@ -762,7 +762,7 @@ <h3 id="_running_tests">3.1. Running Tests</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">The execution of each test method stops as soon as any error or a assertion failure is encountered, and the test suite continues with the next method. All test methods are executed in alphabetical order.</td>
</tr></table>
@@ -772,7 +772,7 @@ <h3 id="_what_to_include_in_your_unit_tests">3.2. What to Include in Your Unit T
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">Many Rails developers practice <em>test-driven development</em> (TDD), in which the tests are written <em>before</em> the code that they are testing. This is an excellent way to build up a test suite that exercises every part of your application. TDD is beyond the scope of this guide, but one place to start is with <a href="http://andrzejonsoftware.blogspot.com/2007/05/15-tdd-steps-to-create-rails.html">15 TDD steps to create a Rails application</a>.</td>
</tr></table>
@@ -956,7 +956,7 @@ <h3 id="_assertions_available">3.3. Assertions Available</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">Creating your own assertions is an advanced topic that we won't cover in this tutorial.</td>
</tr></table>
@@ -1266,7 +1266,7 @@ <h3 id="_testing_views">4.6. Testing Views</h3>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/note.png" alt="Note" />
+<img src="./images/icons/note.png" alt="Note" />
</td>
<td class="content">You may find references to <tt>assert_tag</tt> in other documentation, but this is now deprecated in favor of <tt>assert_select</tt>.</td>
</tr></table>
@@ -1696,7 +1696,7 @@ <h2 id="_rake_tasks_for_testing">7. Rake Tasks for Testing</h2>
<div class="admonitionblock">
<table><tr>
<td class="icon">
-<img src="/Users/lifo/Docs/docrails/railties/doc/guides/source/icons/tip.png" alt="Tip" />
+<img src="./images/icons/tip.png" alt="Tip" />
</td>
<td class="content">You can see all these rake task and their descriptions by running <tt>rake &#8212;tasks &#8212;describe</tt></td>
</tr></table>
View
85 railties/doc/guides/source/finders.txt
@@ -183,7 +183,17 @@ SELECT * FROM clients LIMIT 5, 5
== Group
-TODO
+The group option for find is useful, for example, if you want to find a collection of the dates orders were created on. We could use the option in this context:
+
+[source, ruby]
+Order.find(:all, :group => "date(created_at)", :order => "created_at")
+
+And this will give us a single Order object for each date that we have orders in our database.
+
+The SQL that would be executed would be something like this:
+
+[source, sql]
+SELECT * FROM `orders` GROUP BY date(created_at)
== Read Only
@@ -203,7 +213,7 @@ client.save
If you're wanting to stop race conditions for a specific record, say for example you're incrementing a single field for a record you can use the lock option to ensure that the record is updated correctly. It's recommended this be used inside a transaction.
-[source, Ruby]
+[source, ruby]
Topic.transaction do
t = Topic.find(params[:id], :lock => true)
t.increment!(:views)
@@ -233,7 +243,7 @@ This query is more efficent, but there's a gotcha. If you have a client who does
When using eager loading you can specify conditions for the columns of the tables inside the eager loading to get back a smaller subset. If, for example, you want to find a client and all their orders within the last two weeks you could use eager loading with conditions for this:
-[source, Ruby]
+[source, ruby]
Client.find(:first, :include => "orders", :conditions => ["orders.created_at >= ? AND orders.created_at <= ?", Time.now - 2.weeks, Time.now])
@@ -368,22 +378,76 @@ Client.exists?(:conditions => "first_name = 'Ryan'")
== Calculations
-=== Count
-
-If you want to see how many records are in your models table you could call `Client.count` and that will return the number. If you want to be more specific and find all the clients with their age present in the database you can use `Client.count(:age)`.
+This section uses count as an example method in this preamble, but the options described apply to all sub-sections.
`count` takes conditions much in the same way `exists?` does:
[source, ruby]
Client.count(:conditions => "first_name = 'Ryan'")
+Which will execute:
+
[source, sql]
SELECT count(*) AS count_all FROM `clients` WHERE (first_name = 1)
-== With Scope
+You can also use `include` or `joins` for this to do something a little more complex:
+
+[source, ruby]
+Client.count(:conditions => "clients.first_name = 'Ryan' AND orders.status = 'received'", :include => "orders")
+
+Which will execute:
+
+[source, sql]
+SELECT count(DISTINCT `clients`.id) AS count_all FROM `clients` LEFT OUTER JOIN `orders` ON orders.client_id = client.id WHERE (clients.first_name = 'name' AND orders.status = 'received')
+
+We specify `clients.first_name` just in case one of our join tables has a field also called `first_name` and we do `orders.status` because that's the name of our join table.
+
+
+=== Count
+
+If you want to see how many records are in your model's table you could call `Client.count` and that will return the number. If you want to be more specific and find all the clients with their age present in the database you can use `Client.count(:age)`.
+
+For options, please see the parent section, Calculations.
+
+=== Average
+
+If you want to see the average of a certain number in one of your tables you can call the `average` method on the class that relates to the table. This method call will look something like this:
+
+[source, ruby]
+Client.average("orders_count")
+
+This will return a number (possibly a floating point number such as 3.14159265) representing the average of the fields.
+
+For options, please see the parent section, <<_calculations, Calculations>>
+
+=== Minimum
+
+If you want to find the minimum value of a field in your table you can call the `minimum` method on the class that relates to the table. This method call will look something like this:
+
+[source, ruby]
+Client.minimum("age")
+
+For options, please see the parent section, <<_calculations, Calculations>>
+
+=== Maximum
+
+If you want to find the maximum value of a field in your table you can call the `maximum` method on the class that relates to the table. This method call will look something like this:
+
+[source, ruby]
+Client.maximum("age")
+
+For options, please see the parent section, <<_calculations, Calculations>>
+
+
+=== Sum
+
+If you want to find the sum of a field for all records in your table you can call the `sum` method on the class that relates to the table. This method call will look something like this:
+
+[source, ruby]
+Client.sum("orders_count")
+
+For options, please see the parent section, <<_calculations, Calculations>>
-TODO
-
== Credits
Thanks to Ryan Bates for his awesome screencast on named scope #108. The information within the named scope section is intentionally similar to it, and without the cast may have not been possible.
@@ -419,3 +483,6 @@ Thanks to Mike Gunderloy for his tips on creating this guide.
=== Tuesday, 21 October 2008
1. Extended named scope guide by adding :include and :joins and find sub-sections.
+
+=== Wednesday, 22 October 2008
+1. Completed calculations section.
View
0 railties/doc/guides/source/icons/README → ...ies/doc/guides/source/images/icons/README
File renamed without changes.
View
0 ...es/doc/guides/source/icons/callouts/1.png → ...guides/source/images/icons/callouts/1.png
File renamed without changes
View
0 ...s/doc/guides/source/icons/callouts/10.png → ...uides/source/images/icons/callouts/10.png
File renamed without changes
View
0 ...s/doc/guides/source/icons/callouts/11.png → ...uides/source/images/icons/callouts/11.png
File renamed without changes
View
0 ...s/doc/guides/source/icons/callouts/12.png → ...uides/source/images/icons/callouts/12.png
File renamed without changes
View
0 ...s/doc/guides/source/icons/callouts/13.png → ...uides/source/images/icons/callouts/13.png
File renamed without changes
View
0 ...s/doc/guides/source/icons/callouts/14.png → ...uides/source/images/icons/callouts/14.png
File renamed without changes
View
0 ...s/doc/guides/source/icons/callouts/15.png → ...uides/source/images/icons/callouts/15.png
File renamed without changes
View
0 ...es/doc/guides/source/icons/callouts/2.png → ...guides/source/images/icons/callouts/2.png
File renamed without changes
View
0 ...es/doc/guides/source/icons/callouts/3.png → ...guides/source/images/icons/callouts/3.png
File renamed without changes
View
0 ...es/doc/guides/source/icons/callouts/4.png → ...guides/source/images/icons/callouts/4.png
File renamed without changes
View
0 ...es/doc/guides/source/icons/callouts/5.png → ...guides/source/images/icons/callouts/5.png
File renamed without changes
View
0 ...es/doc/guides/source/icons/callouts/6.png → ...guides/source/images/icons/callouts/6.png
File renamed without changes
View
0 ...es/doc/guides/source/icons/callouts/7.png → ...guides/source/images/icons/callouts/7.png
File renamed without changes
View
0 ...es/doc/guides/source/icons/callouts/8.png → ...guides/source/images/icons/callouts/8.png
File renamed without changes
View
0 ...es/doc/guides/source/icons/callouts/9.png → ...guides/source/images/icons/callouts/9.png
File renamed without changes
View
0 railties/doc/guides/source/icons/caution.png → ...oc/guides/source/images/icons/caution.png
File renamed without changes
View
0 railties/doc/guides/source/icons/example.png → ...oc/guides/source/images/icons/example.png
File renamed without changes
View
0 railties/doc/guides/source/icons/home.png → ...s/doc/guides/source/images/icons/home.png
File renamed without changes
View
0 ...ies/doc/guides/source/icons/important.png → .../guides/source/images/icons/important.png
File renamed without changes
View
0 railties/doc/guides/source/icons/next.png → ...s/doc/guides/source/images/icons/next.png
File renamed without changes
View
0 railties/doc/guides/source/icons/note.png → ...s/doc/guides/source/images/icons/note.png
File renamed without changes
View
0 railties/doc/guides/source/icons/prev.png → ...s/doc/guides/source/images/icons/prev.png
File renamed without changes
View
0 railties/doc/guides/source/icons/tip.png → ...es/doc/guides/source/images/icons/tip.png
File renamed without changes
View
0 railties/doc/guides/source/icons/up.png → ...ies/doc/guides/source/images/icons/up.png
File renamed without changes
View
0 railties/doc/guides/source/icons/warning.png → ...oc/guides/source/images/icons/warning.png
File renamed without changes
View
2 railties/lib/tasks/documentation.rake
@@ -61,7 +61,7 @@ namespace :doc do
FileUtils.cp_r File.join(source, 'html/.'), File.join(destination)
# Copy images and css files to html directory. These dirs are in .gitigore and shouldn't be source controlled.
- FileUtils.cp_r File.join(source, 'source/images'), File.join(destination, 'images')
+ FileUtils.cp_r File.join(source, 'source/images'), File.join(destination)
FileUtils.cp_r File.join(source, 'source/stylesheets'), File.join(destination, 'stylesheets')
end

0 comments on commit 896058b

Please sign in to comment.