The parameter you get from the browser is a string (based on your comment on another answer: "Instead of true and false, although it uses 0 and 1." parent "=> {" children "=>" 1 "}") . Your check checks if it is logical.
I suggest the following solution:
First, delete your def self.children=() method, it does nothing in your current implementation (this is a class method and is never called).
Then we implement a custom accessory that converts the String parameter to a logical one:
class Parent attr_reader :children def children=(string_value) @children = (string_value == '1') end validates_inclusion_of :children, :in => [true, false] end
In doing so, your original check should work fine.
source share