Menu

📰
0

Casting and assertion of params sent on http request

Reddit r/rails·u/Rustepo·about 1 month ago
#EZ7E2adJ
Reading 0:00
15s threshold

What's the community 'most liked' approach to assert on a request, on query or body parameters, the param[:foo] is actually true otherwise you do other thing.

Do you use?

  1. if params[:foo]

  2. if params[:foo].to_s == "true"

  3. if params[:foo].presence?

  4. if ActiveModel::Type::Boolean.new.cast(params[:foo])

Just curious on what do you use.

Read More