Closed geniousli closed 8 years ago
Can you clarify exactly what code you are running? Please also include the versions of Rails and active_type you are running as well as which database adapter you are using
I just tried this example and it works fine:
class Example < ActiveType::Object
attribute :subscribe, :boolean
def test
if self.subscribe
"Subscribe"
else
"Not subscribe"
end
end
end
e = Example.new
e.subscribe = false
e.test # => "Not subscribe"
e.subscribe = true
e.test # => "Subscribe"
mysql 5.6.23
class Subscribe < ActiveType::Object
attribute :subscribe, :boolean
def test
if self.subscribe
"Subscribe"
else
"Not subscribe"
end
end
end
sub = Subscribe.new(subscribe: false)
sub.test #=> "Subscribe"
sub.subscribe = false
sub.test #=> "Subscribe"
i am sorry for the first Issue format, i don't know it support markdown, thank for you patience
OK, I can confirm this is a bug. I am seeing the same failing boolean behavior with:
The bug also exists with active_type master
@ 937306d.
@henning-koch this seems to be a duplicate of #34.
yes, They are looks the same
I hope this was fixed in 0.4.3.
class Users::Subscribe < ActiveType::Object attribute :subscribe, :boolean def test if self.subscribe
.....
end end
when i call test method, if statement in test method always passed, even i pass false to subscribe attribute, does it a bug, or designed?