aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-01-24 11:20:47 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-01-24 11:20:47 +0000
commit1d618455870cac504256cd762cd0787c739dfe1f (patch)
tree34fe4009e1bab6cf722538b7c29dcb9aeab50a66 /activerecord/lib/active_record
parent3d1e8dde9d023cc3d2c75dea689648434050d621 (diff)
downloadrails-1d618455870cac504256cd762cd0787c739dfe1f.tar.gz
rails-1d618455870cac504256cd762cd0787c739dfe1f.tar.bz2
rails-1d618455870cac504256cd762cd0787c739dfe1f.zip
Fixed that records fetched with piggy-back attributes or through rich has_and_belongs_to_many associations couldn't be saved due to the extra attributes not part of the table #522 [Eric Anderson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@483 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-xactiverecord/lib/active_record/base.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 8ae636afbb..ede60e3f6d 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1115,10 +1115,11 @@ module ActiveRecord #:nodoc:
# an SQL statement.
def attributes_with_quotes(include_primary_key = true)
columns_hash = self.class.columns_hash
- @attributes.inject({}) do |attrs_quoted, pair|
+ attrs_quoted = @attributes.inject({}) do |attrs_quoted, pair|
attrs_quoted[pair.first] = quote(pair.last, columns_hash[pair.first]) unless !include_primary_key && pair.first == self.class.primary_key
attrs_quoted
end
+ attrs_quoted.delete_if { | key, value | !self.class.columns_hash.keys.include?(key) }
end
# Quote strings appropriately for SQL statements.