Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated method for sanitization of protected attributes in Rails 3

  • Loading branch information...
commit 49c8f02f3edbf98e66b983f1b952bb92f38fdbaa 1 parent 2404b88
Josh Delsman authored
Showing with 9 additions and 4 deletions.
  1. +9 −4 lib/state_machine/integrations/active_record.rb
View
13 lib/state_machine/integrations/active_record.rb
@@ -414,13 +414,18 @@ def initialize(attributes = nil, *args)
def attributes=(new_attributes, *args)
if new_record? && !@initialized_state_machines
@initialized_state_machines = true
-
- if new_attributes
+
+ ignore = if new_attributes
attributes = new_attributes.dup
attributes.stringify_keys!
- ignore = remove_attributes_protected_from_mass_assignment(attributes).keys
+
+ if respond_to? :sanitize_for_mass_assignment
+ sanitize_for_mass_assignment(attributes).keys
+ else
+ remove_attributes_protected_from_mass_assignment(attributes).keys
+ end
else
- ignore = []
+ []
end
initialize_state_machines(:dynamic => false, :ignore => ignore)
Please sign in to comment.
Something went wrong with that request. Please try again.