Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4650

How to deserialize boolean params.permit value correctly to make sure it's boolean in Rails

$
0
0

There are params to permit:

{"string_value": "value","boolean_value": "true/false","other_value": "blabla"}

I need to convert the boolean_value to Boolean like this ActiveRecord::Type::Boolean.new.deserialize but when I permit params:

ActiveRecord::Type::Boolean.new.deserialize(params.permit(:boolean_value)[:boolean_value])

it doesn't work correctly because the result is always true.How do I pass and permit this param correctly?


Viewing all articles
Browse latest Browse all 4650

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>