aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2010-09-30 23:29:23 +0100
committerJon Leighton <j@jonathanleighton.com>2010-09-30 23:29:23 +0100
commit704961ce688f5bc1942529f44ea6b00014ef8378 (patch)
treeb951112aed4914cdc4203bca6e810a7b71d37e82 /activemodel/lib
parentb689834bcf2730353d066277f43047f10abb8d30 (diff)
parent91deff08c940f16ed149e7628694faff0393fe0a (diff)
downloadrails-704961ce688f5bc1942529f44ea6b00014ef8378.tar.gz
rails-704961ce688f5bc1942529f44ea6b00014ef8378.tar.bz2
rails-704961ce688f5bc1942529f44ea6b00014ef8378.zip
Merge branch 'master' into nested_has_many_through_2
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/naming.rb6
-rw-r--r--activemodel/lib/active_model/validations/confirmation.rb4
2 files changed, 7 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb
index fc2abacb6d..2d580fd325 100644
--- a/activemodel/lib/active_model/naming.rb
+++ b/activemodel/lib/active_model/naming.rb
@@ -73,8 +73,10 @@ module ActiveModel
# Returns an ActiveModel::Name object for module. It can be
# used to retrieve all kinds of naming-related information.
def model_name
- namespace = self.parents.detect { |n| n.respond_to?(:_railtie) }
- @_model_name ||= ActiveModel::Name.new(self, namespace)
+ @_model_name ||= begin
+ namespace = self.parents.detect { |n| n.respond_to?(:_railtie) }
+ ActiveModel::Name.new(self, namespace)
+ end
end
# Returns the plural class name of a record or class. Examples:
diff --git a/activemodel/lib/active_model/validations/confirmation.rb b/activemodel/lib/active_model/validations/confirmation.rb
index 2c8a840124..00df10cef0 100644
--- a/activemodel/lib/active_model/validations/confirmation.rb
+++ b/activemodel/lib/active_model/validations/confirmation.rb
@@ -10,7 +10,9 @@ module ActiveModel
end
def setup(klass)
- klass.send(:attr_accessor, *attributes.map { |attribute| :"#{attribute}_confirmation" })
+ klass.send(:attr_accessor, *attributes.map do |attribute|
+ :"#{attribute}_confirmation" unless klass.method_defined?(:"#{attribute}_confirmation")
+ end.compact)
end
end