Open prioux opened 1 month ago
Well, I would go for variant 2 because it is probably enough to override read_only?
method in the parent class and it affects the method immediately on creation. Also, optionally, variant 1 can be implemented in the same time, just to make database more consistent
Actually not only boolean, any attribute has 'truthiness/presentishness' check method, which differs only in question mark, something like name?
, type?
, 'description?' etc ... Note integer 0 considered by falthy falue.
Some DPs are meant to be read-only. Usually, they inform the rest of the system by just overriding the method read_only() in this way:
The attribute read_only is a database column. However, for boolean columns, Rails also provide
read_only?
. Since that method is not overridden, it returns false if the DB's value has not been set. So we get this kind of behavior:There are several solutions. Not sure what is best.
1) make sure the DB column is also consistent; maybe with a general callback in after_update() ? 2) override
read_only?
too 3) ... 4) profit! 5) my slashdot ID is 5 digits long