Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use update_attribute instead of update_attributes to prevent masss-as…

…signment exceptions [refs #15]
  • Loading branch information...
commit 2c92d1a963be4a40c971b4d1b1a14fb7e3c9b0c8 1 parent 49e8e22
@ayrton authored
Showing with 5 additions and 8 deletions.
  1. +2 −2 lib/defender/spammable.rb
  2. +3 −6 lib/defender/test/comment.rb
View
4 lib/defender/spammable.rb
@@ -114,7 +114,7 @@ def false_positive!
if document['status'] == 'failed'
raise DefenderError, document['message']
end
- update_attributes(:spam => false)
+ update_attribute(:spam, false)
end
# Public: Report a false negative to Defensio and update the spam
@@ -132,7 +132,7 @@ def false_negative!
if document['status'] == 'failed'
raise DefenderError, document['message']
end
- update_attributes(:spam => true)
+ update_attribute(:spam, true)
end
# Public: Pass in more data to be sent to Defensio. You should use this
View
9 lib/defender/test/comment.rb
@@ -40,12 +40,9 @@ def save(with_callbacks=true)
end
end
- # Update the attributes with the names of the keys in the hash.
- def update_attributes(hash={})
- hash.each do |key, value|
- self.send("#{key}=", value)
- end
- save
+ def update_attribute(name, value)
+ self.send("#{name}=".to_sym, value)
+ self.save
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.