diff options
author | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-14 17:38:30 -0700 |
---|---|---|
committer | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-14 17:38:30 -0700 |
commit | b6bac73b282c7e500c43810f2a937fc0047e5979 (patch) | |
tree | b234951c42e4c682ef723320287383ac3fff0cf1 /activerecord/lib | |
parent | da65320433088548bc4cff33758e5acd71fd137a (diff) | |
parent | c286952050e8fe16b0f6d64ba0687b52cc8f2ae1 (diff) | |
download | rails-b6bac73b282c7e500c43810f2a937fc0047e5979.tar.gz rails-b6bac73b282c7e500c43810f2a937fc0047e5979.tar.bz2 rails-b6bac73b282c7e500c43810f2a937fc0047e5979.zip |
Merge commit 'origin/master'
Conflicts:
actionpack/lib/action_controller/abstract/base.rb
actionpack/lib/action_controller/routing.rb
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods.rb | 6 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 13 |
2 files changed, 7 insertions, 12 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 55d9a4d15d..d5e215af9d 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -105,8 +105,8 @@ module ActiveRecord def instance_method_already_implemented?(method_name) method_name = method_name.to_s return true if method_name =~ /^id(=$|\?$|$)/ - @_defined_class_methods ||= ancestors.first(ancestors.index(ActiveRecord::Base)).sum([]) { |m| m.public_instance_methods(false) | m.private_instance_methods(false) | m.protected_instance_methods(false) }.map(&:to_s).to_set - @@_defined_activerecord_methods ||= (ActiveRecord::Base.public_instance_methods(false) | ActiveRecord::Base.private_instance_methods(false) | ActiveRecord::Base.protected_instance_methods(false)).map(&:to_s).to_set + @_defined_class_methods ||= ancestors.first(ancestors.index(ActiveRecord::Base)).sum([]) { |m| m.public_instance_methods(false) | m.private_instance_methods(false) | m.protected_instance_methods(false) }.map {|m| m.to_s }.to_set + @@_defined_activerecord_methods ||= (ActiveRecord::Base.public_instance_methods(false) | ActiveRecord::Base.private_instance_methods(false) | ActiveRecord::Base.protected_instance_methods(false)).map{|m| m.to_s }.to_set raise DangerousAttributeError, "#{method_name} is defined by ActiveRecord" if @@_defined_activerecord_methods.include?(method_name) @_defined_class_methods.include?(method_name) end @@ -124,7 +124,7 @@ module ActiveRecord # with datatype <tt>:datetime, :timestamp, :time, :date</tt> are cached. def cached_attributes @cached_attributes ||= - columns.select{|c| attribute_types_cached_by_default.include?(c.type)}.map(&:name).to_set + columns.select{|c| attribute_types_cached_by_default.include?(c.type)}.map{|col| col.name}.to_set end # Returns +true+ if the provided attribute is being cached. diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index b9ba727a3f..ca4f4fa6b6 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -697,14 +697,9 @@ module ActiveRecord #:nodoc: # Person.exists?(['name LIKE ?', "%#{query}%"]) # Person.exists? def exists?(id_or_conditions = {}) - connection.select_all( - construct_finder_sql( - :select => "#{quoted_table_name}.#{primary_key}", - :conditions => expand_id_conditions(id_or_conditions), - :limit => 1 - ), - "#{name} Exists" - ).size > 0 + find_initial( + :select => "#{quoted_table_name}.#{primary_key}", + :conditions => expand_id_conditions(id_or_conditions)) ? true : false end # Creates an object (or multiple objects) and saves it to the database, if validations pass. @@ -1040,7 +1035,7 @@ module ActiveRecord #:nodoc: # To start from an all-closed default and enable attributes as needed, # have a look at +attr_accessible+. def attr_protected(*attributes) - write_inheritable_attribute(:attr_protected, Set.new(attributes.map(&:to_s)) + (protected_attributes || [])) + write_inheritable_attribute(:attr_protected, Set.new(attributes.map {|a| a.to_s}) + (protected_attributes || [])) end # Returns an array of all the attributes that have been protected from mass-assignment. |