Permalink
Browse files

Updated should_protect_attributes to fix issue when attr_protected is…

… used and attribute is missing.
  • Loading branch information...
1 parent ebd37ea commit 2d2c1a477e69e5c601f9d7f77c52a5a8cef6b8f1 @boone boone committed with rmm5t Sep 3, 2008
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/shoulda/active_record/macros.rb
@@ -118,7 +118,8 @@ def should_protect_attributes(*attributes)
protected = klass.protected_attributes || []
accessible = klass.accessible_attributes || []
- assert protected.include?(attribute.to_s) || !accessible.include?(attribute.to_s),
+ assert protected.include?(attribute.to_s) ||
+ (!accessible.empty? && !accessible.include?(attribute.to_s)),
(accessible.empty? ?
"#{klass} is protecting #{protected.to_a.to_sentence}, but not #{attribute}." :
"#{klass} has made #{attribute} accessible")

0 comments on commit 2d2c1a4

Please sign in to comment.