aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-09-13 19:09:01 +0100
committerJon Leighton <j@jonathanleighton.com>2011-09-13 19:09:01 +0100
commit11870117c6d9231b79e8125218728423e9dff207 (patch)
treeb338cd9b232ac0ecb0863463f382cf5b30037436 /activerecord/lib
parentd3baa928312a13ddd550a527caa554a49267ce88 (diff)
downloadrails-11870117c6d9231b79e8125218728423e9dff207.tar.gz
rails-11870117c6d9231b79e8125218728423e9dff207.tar.bz2
rails-11870117c6d9231b79e8125218728423e9dff207.zip
Rename first_or_new to first_or_initialize.
For consistency with find_or_initialize_by. Also remove first_or_build alias.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/base.rb2
-rw-r--r--activerecord/lib/active_record/relation.rb3
2 files changed, 2 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 92f80c6eaa..558b341c06 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -442,7 +442,7 @@ module ActiveRecord #:nodoc:
class << self # Class methods
delegate :find, :first, :first!, :last, :last!, :all, :exists?, :any?, :many?, :to => :scoped
- delegate :first_or_create, :first_or_create!, :first_or_new, :first_or_build, :to => :scoped
+ delegate :first_or_create, :first_or_create!, :first_or_initialize, :to => :scoped
delegate :destroy, :destroy_all, :delete, :delete_all, :update, :update_all, :to => :scoped
delegate :find_each, :find_in_batches, :to => :scoped
delegate :select, :group, :order, :except, :reorder, :limit, :offset, :joins, :where, :preload, :eager_load, :includes, :from, :lock, :readonly, :having, :create_with, :to => :scoped
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index d3f1347e03..ecefaa633c 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -132,10 +132,9 @@ module ActiveRecord
# 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(attributes = nil, options = {}, &block)
+ def first_or_initialize(attributes = nil, options = {}, &block)
first || new(attributes, options, &block)
end
- alias :first_or_build :first_or_new
def respond_to?(method, include_private = false)
arel.respond_to?(method, include_private) ||