I have a Logo model that has fields of name:string, default:boolean. I want the true value to be unique, so that only one item in the database can be set to true at once. How do
I think it's good to check if the one you save is true before you falsify others. Otherwise you falsify everyone when you save a record that isn't active.
def falsify_all_others
if self.default
self.class.where('id != ? and default', self.id).update_all("default = 'false'")
end
end