aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/association_basics.textile
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2011-10-14 22:21:40 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2011-10-14 22:21:40 +0530
commite759c8882a990606bb4aee8a643431ebe544c69f (patch)
treedea32e65055a6e67d89f106cf696ae7ef358619a /railties/guides/source/association_basics.textile
parent521a089166a17d447c3b3b32ff7f9394774ca895 (diff)
parente2a3952428050ea8a22c6a7de27f30ee0b9b1d4d (diff)
downloadrails-e759c8882a990606bb4aee8a643431ebe544c69f.tar.gz
rails-e759c8882a990606bb4aee8a643431ebe544c69f.tar.bz2
rails-e759c8882a990606bb4aee8a643431ebe544c69f.zip
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'railties/guides/source/association_basics.textile')
-rw-r--r--railties/guides/source/association_basics.textile6
1 files changed, 2 insertions, 4 deletions
diff --git a/railties/guides/source/association_basics.textile b/railties/guides/source/association_basics.textile
index 479a3c1e30..6829eb8ef4 100644
--- a/railties/guides/source/association_basics.textile
+++ b/railties/guides/source/association_basics.textile
@@ -1229,17 +1229,15 @@ end
If you use a hash-style +:conditions+ option, then record creation via this association will be automatically scoped using the hash. In this case, using +@customer.confirmed_orders.create+ or +@customer.confirmed_orders.build+ will create orders where the confirmed column has the value +true+.
-If you need to evaluate conditions dynamically at runtime, you could use string interpolation in single quotes:
+If you need to evaluate conditions dynamically at runtime, use a proc:
<ruby>
class Customer < ActiveRecord::Base
has_many :latest_orders, :class_name => "Order",
- :conditions => 'orders.created_at > #{10.hours.ago.to_s(:db).inspect}'
+ :conditions => proc { "orders.created_at > #{10.hours.ago.to_s(:db).inspect}" }
end
</ruby>
-Be sure to use single quotes.
-
h6(#has_many-counter_sql). +:counter_sql+
Normally Rails automatically generates the proper SQL to count the association members. With the +:counter_sql+ option, you can specify a complete SQL statement to count them yourself.