From 72317883ed3fd035a94ca1536def364d2d00a6c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Mej=C3=ADa?= Date: Tue, 6 Sep 2011 02:45:54 -0500 Subject: [PATCH] Using more precise method signatures for AR::Relation#first_or_create family of methods. --- activerecord/lib/active_record/relation.rb | 12 ++++++------ 1 file 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 @@ def create!(*args, &block) # user.last_name = "O'Hara" # end # # => - 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 first_or_create but calls create! so an exception is raised if the created record is invalid. # # Expects arguments in the same format as Base.create!. - 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 first_or_create but calls new instead of create. # # Expects arguments in the same format as Base.new. - 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 -- GitLab