Skip to content

Commit

Permalink
Apply Tony Hillerson's patch for Rails 2.1. I found this fixed failur…
Browse files Browse the repository at this point in the history
…es that occurred when calling update_attributes on models that use BNS. See: http://rubyforge.org/pipermail/betternestedset-talk/2008-July/000336.html
  • Loading branch information
chris committed Jul 15, 2008
1 parent 0a10890 commit 2305b85
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/better_nested_set.rb
Expand Up @@ -1093,13 +1093,14 @@ def calculate_reorder_steps(ordered_ids, current)
private
# override the sql preparation method to exclude the lft/rgt columns
# under the same conditions that the primary key column is excluded
def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = true) #:nodoc:
def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys) #:nodoc:
left_and_right_column = [acts_as_nested_set_options[:left_column], acts_as_nested_set_options[:right_column]]
quoted = attributes.inject({}) do |quoted, (name, value)|
quoted = {}
connection = self.class.connection
attribute_names.each do |name|
if column = column_for_attribute(name)
quoted[name] = quote_value(value, column) unless !include_primary_key && (column.primary || left_and_right_column.include?(column.name))
quoted[name] = connection.quote(read_attribute(name), column) unless !include_primary_key && (column.primary || left_and_right_column.include?(column.name))
end
quoted
end
include_readonly_attributes ? quoted : remove_readonly_attributes(quoted)
end
Expand Down

0 comments on commit 2305b85

Please sign in to comment.