active records' #attributes=() signature changed. so let's change as well

pull/1186/head
Martin Linkhorst 12 years ago
parent ad88ba7461
commit 52294f5a68
  1. 4
      app/models/issue.rb
  2. 22
      config/initializers/mass_assignment.rb

@ -225,13 +225,13 @@ class Issue < ActiveRecord::Base
end end
# Overrides attributes= so that tracker_id gets assigned first # Overrides attributes= so that tracker_id gets assigned first
def attributes_with_tracker_first=(new_attributes, *args) def attributes_with_tracker_first=(new_attributes)
return if new_attributes.nil? return if new_attributes.nil?
new_tracker_id = new_attributes['tracker_id'] || new_attributes[:tracker_id] new_tracker_id = new_attributes['tracker_id'] || new_attributes[:tracker_id]
if new_tracker_id if new_tracker_id
self.tracker_id = new_tracker_id self.tracker_id = new_tracker_id
end end
send :attributes_without_tracker_first=, new_attributes, *args send :attributes_without_tracker_first=, new_attributes
end end
# Do not redefine alias chain on reload (see #4838) # Do not redefine alias chain on reload (see #4838)
alias_method_chain(:attributes=, :tracker_first) unless method_defined?(:attributes_without_tracker_first=) alias_method_chain(:attributes=, :tracker_first) unless method_defined?(:attributes_without_tracker_first=)

@ -1,26 +1,6 @@
class ActiveRecord::Base class ActiveRecord::Base
# for full security the following call will disallow any attributes by default
# attr_accessible
# call this to force mass assignment even of protected attributes # call this to force mass assignment even of protected attributes
def force_attributes=(new_attributes) def force_attributes=(new_attributes)
self.send(:attributes=, new_attributes, false) self.send(:assign_attributes, new_attributes, :without_protection => true)
end end
# this override will protected the foreign key of certain belongs_to associations by default (see #protected_association?)
# def self.belongs_to(association_id, options = {})
# ret = super
# if protected_association? association_id
# foreign_key = options[:foreign_key] || "#{association_id}_id"
# attr_protected foreign_key
# end
# ret
# end
private
# def protected_association?(association_id)
# PROTECTED_ASSOCIATIONS.include? association_id.to_s
# end
#
# PROTECTED_ASSOCIATIONS = %w[project user author]
end end

Loading…
Cancel
Save