aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrés Mejía <andmej@gmail.com>2011-09-06 02:45:54 -0500
committerAndrés Mejía <andmej@gmail.com>2011-09-06 02:45:54 -0500
commit72317883ed3fd035a94ca1536def364d2d00a6c6 (patch)
treeefd2ce32aebb438f29ce31956666688adab9c3d3
parentd03aff7f645bdc16eae35264bb0e95a0ab814d15 (diff)
downloadrails-72317883ed3fd035a94ca1536def364d2d00a6c6.tar.gz
rails-72317883ed3fd035a94ca1536def364d2d00a6c6.tar.bz2
rails-72317883ed3fd035a94ca1536def364d2d00a6c6.zip
Using more precise method signatures for AR::Relation#first_or_create family of methods.
-rw-r--r--activerecord/lib/active_record/relation.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 849f01a047..d3f1347e03 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -118,22 +118,22 @@ module ActiveRecord
# user.last_name = "O'Hara"
# end
# # => <User id: 2, first_name: 'Scarlett', last_name: 'Johansson'>
- def first_or_create(*args, &block)
- first || create(*args, &block)
+ def first_or_create(attributes = nil, options = {}, &block)
+ first || create(attributes, options, &block)
end
# Like <tt>first_or_create</tt> but calls <tt>create!</tt> so an exception is raised if the created record is invalid.
#
# Expects arguments in the same format as <tt>Base.create!</tt>.
- def first_or_create!(*args, &block)
- first || create!(*args, &block)
+ def first_or_create!(attributes = nil, options = {}, &block)
+ first || create!(attributes, options, &block)
end
# Like <tt>first_or_create</tt> but calls <tt>new</tt> instead of <tt>create</tt>.
#
# Expects arguments in the same format as <tt>Base.new</tt>.
- def first_or_new(*args, &block)
- first || new(*args, &block)
+ def first_or_new(attributes = nil, options = {}, &block)
+ first || new(attributes, options, &block)
end
alias :first_or_build :first_or_new