aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2011-07-23 01:59:46 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2011-07-23 01:59:46 +0530
commit573c6e6982224e6817174d2f9c288b6ddc938608 (patch)
tree4e845e9dfadd841b0745b631418ae5f4a1ba7930
parentccb3af468328270b38e4a31ee0e353fd1d7ec327 (diff)
downloadrails-573c6e6982224e6817174d2f9c288b6ddc938608.tar.gz
rails-573c6e6982224e6817174d2f9c288b6ddc938608.tar.bz2
rails-573c6e6982224e6817174d2f9c288b6ddc938608.zip
document the change in edge rails which makes a more strict check on the arity of the dynamic finders
-rw-r--r--railties/guides/source/active_record_querying.textile1
1 files changed, 1 insertions, 0 deletions
diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile
index 082f9eda7d..8ea06d28aa 100644
--- a/railties/guides/source/active_record_querying.textile
+++ b/railties/guides/source/active_record_querying.textile
@@ -1016,6 +1016,7 @@ You can specify an exclamation point (<tt>!</tt>) on the end of the dynamic find
If you want to find both by name and locked, you can chain these finders together by simply typing +and+ between the fields. For example, +Client.find_by_first_name_and_locked("Ryan", true)+.
+WARNING: Up to and including Rails 3.1, when the number of arguments passed to a dynamic finder method is lesser than the number of fields, say <tt>Client.find_by_name_and_locked("Ryan")</tt>, the behavior is to pass +nil+ as the missing argument. This is *unintentional* and this behavior will be changed in Rails 3.2 to throw an +ArgumentError+.
There's another set of dynamic finders that let you find or create/initialize objects if they aren't found. These work in a similar fashion to the other finders and can be used like +find_or_create_by_first_name(params[:first_name])+. Using this will first perform a find and then create if the find returns +nil+. The SQL looks like this for +Client.find_or_create_by_first_name("Ryan")+: