Skip to content

Commit

Permalink
Use update_attribute instead of update_attributes to prevent masss-as…
Browse files Browse the repository at this point in the history
…signment exceptions [refs sarahhodne-abandoned#15]
  • Loading branch information
ayrton committed Mar 26, 2012
1 parent 49e8e22 commit 2c92d1a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/defender/spammable.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 3 additions & 6 deletions lib/defender/test/comment.rb
Expand Up @@ -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

0 comments on commit 2c92d1a

Please sign in to comment.