Skip to content

Instantly share code, notes, and snippets.

@alvarobp
Created September 3, 2009 12:58
Show Gist options
  • Save alvarobp/180284 to your computer and use it in GitHub Desktop.
Save alvarobp/180284 to your computer and use it in GitHub Desktop.
class ActiveRecord::Base
def force_update_attribute(attribute, value)
self.connection.update_sql("UPDATE #{self.class.name.tableize} SET #{attribute.to_s} = #{self.connection.quote(value)} WHERE id = #{self.connection.quote(id)}")
self.reload
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment