From c3f53f412cd170fc295b46e48aa81837ad15ec83 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Fri, 19 Dec 2008 14:27:43 +0000 Subject: Merge docrails --- railties/doc/guides/html/finders.html | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'railties/doc/guides/html/finders.html') diff --git a/railties/doc/guides/html/finders.html b/railties/doc/guides/html/finders.html index c2c1db99e3..603f488cc9 100644 --- a/railties/doc/guides/html/finders.html +++ b/railties/doc/guides/html/finders.html @@ -609,6 +609,7 @@ http://www.gnu.org/software/src-highlite -->

6. Selecting Certain Fields

To select certain fields, you can use the select option like this: Client.first(:select ⇒ "viewable_by, locked"). This select option does not use an array of fields, but rather requires you to type SQL-like code. The above code will execute SELECT viewable_by, locked FROM clients LIMIT 0,1 on your database.

+

You can also call SQL functions within the select option. For example, if you would like to only grab a single record per unique value in a certain field by using the DISTINCT function you can do it like this: Client.all(:select ⇒ "DISTINCT(name)").

7. Limit & Offset

@@ -1051,6 +1052,11 @@ http://www.gnu.org/software/src-highlite -->
  • +December 1 2008: Added using an SQL function example to Selecting Certain Fields section as per this ticket +

    +
  • +
  • +

    November 23 2008: Added documentation for find_by_last and find_by_bang!

  • -- cgit v1.2.3