aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/active_support_core_extensions.textile
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2009-10-25 20:21:38 +0100
committerXavier Noria <fxn@hashref.com>2009-10-25 20:21:38 +0100
commit24a85e0ee50a51631a065825134a32e09685a795 (patch)
treea11605c006500473bda6252a2e9f3274a62cc365 /railties/guides/source/active_support_core_extensions.textile
parente7b3ad535b7deefecd7d14ec3631757073ea3f39 (diff)
downloadrails-24a85e0ee50a51631a065825134a32e09685a795.tar.gz
rails-24a85e0ee50a51631a065825134a32e09685a795.tar.bz2
rails-24a85e0ee50a51631a065825134a32e09685a795.zip
AS guide: documents the extension to Range#to_s
Diffstat (limited to 'railties/guides/source/active_support_core_extensions.textile')
-rw-r--r--railties/guides/source/active_support_core_extensions.textile14
1 files changed, 14 insertions, 0 deletions
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile
index e137eb436f..6bd1e3acbb 100644
--- a/railties/guides/source/active_support_core_extensions.textile
+++ b/railties/guides/source/active_support_core_extensions.textile
@@ -1625,6 +1625,20 @@ This method is also used in the routes code for building regexps.
h3. Extensions to +Range+
+h4. +to_s+
+
+Active Support extends the method +Range#to_s+ so that it understands an optional format argument. As of this writing the only supported non-default format is +:db+:
+
+<ruby>
+(Date.today..Date.tomorrow).to_s
+# => "2009-10-25..2009-10-26"
+
+(Date.today..Date.tomorrow).to_s(:db)
+# => "BETWEEN '2009-10-25' AND '2009-10-26'"
+</ruby>
+
+As the example depicts, the +:db+ format generates a +BETWEEN+ SQL clause. That is used by Active Record in its support for range values in conditions.
+
h4. +step+
Active Support extends the method +Range#step+ so that it can be invoked without a block: