Say I have a Item model, which has a boolean onshelf.
I want to explicitly set onshelf value to true by doing something like self.onshelf = true. But I learn in the book Agile Web Development that, different database stores boolean value quite differently, and I’m afraid my practice might break my app in the future.
So I want to know, if I set boolean like self.onshelf = true, will Rails performs type-conversion (correctly)?
I know that toggle! method can do this too, but I don’t like it to immediately save the result. I want to set every attribute first, then let after_save decides.
Thanks!
ActiveRecord (with its database drivers) will store boolean’s in a way most appropriate for the particular database you’re using.