aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorAkira Matsuda <ronnie@dio.jp>2013-01-02 05:07:32 +0900
committerAkira Matsuda <ronnie@dio.jp>2013-01-02 05:12:16 +0900
commit2565c81862a7dc5cc2ab058d7fb25759aab1af7b (patch)
tree04227c76519baf01d36e0460be7b8fd2f13867a6 /activerecord/lib/active_record/base.rb
parent44717a9d548c95c7b01e7e0dce061257b3a93646 (diff)
downloadrails-2565c81862a7dc5cc2ab058d7fb25759aab1af7b.tar.gz
rails-2565c81862a7dc5cc2ab058d7fb25759aab1af7b.tar.bz2
rails-2565c81862a7dc5cc2ab058d7fb25759aab1af7b.zip
find_or_create_by is deprecated in AR 4
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rw-r--r--activerecord/lib/active_record/base.rb25
1 files changed, 0 insertions, 25 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 3d374fe9b4..0a3fdef5a5 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -179,23 +179,6 @@ module ActiveRecord #:nodoc:
#
# Payment.order("created_on").find_by_amount(50)
#
- # The same dynamic finder style can be used to create the object if it doesn't already exist.
- # This dynamic finder is called with <tt>find_or_create_by_</tt> and will return the object if
- # it already exists and otherwise creates it, then returns it. Protected attributes won't be set
- # unless they are given in a block.
- #
- # # No 'Summer' tag exists
- # Tag.find_or_create_by_name("Summer") # equal to Tag.create(name: "Summer")
- #
- # # Now the 'Summer' tag does exist
- # Tag.find_or_create_by_name("Summer") # equal to Tag.find_by_name("Summer")
- #
- # # Now 'Bob' exist and is an 'admin'
- # User.find_or_create_by_name('Bob', age: 40) { |u| u.admin = true }
- #
- # Adding an exclamation point (!) on to the end of <tt>find_or_create_by_</tt> will
- # raise an <tt>ActiveRecord::RecordInvalid</tt> error if the new record is invalid.
- #
# Use the <tt>find_or_initialize_by_</tt> finder if you want to return a new record without
# saving it first. Protected attributes won't be set unless they are given in a block.
#
@@ -203,14 +186,6 @@ module ActiveRecord #:nodoc:
# winter = Tag.find_or_initialize_by_name("Winter")
# winter.persisted? # false
#
- # To find by a subset of the attributes to be used for instantiating a new object, pass a hash instead of
- # a list of parameters.
- #
- # Tag.find_or_create_by_name(name: "rails", creator: current_user)
- #
- # That will either find an existing tag named "rails", or create a new one while setting the
- # user that created it.
- #
# == Saving arrays, hashes, and other non-mappable objects in text columns
#
# Active Record can serialize any object in text columns using YAML. To do so, you must