How to check if a param is true or false?

Viewed 38230

This is really racking my brain, but maybe I'm trying to hard.

I'm passing a param via a URL (example.com?debug=true)

So I basically want to say:

if params[:debug] == true
 do xyz
else
 do abc
end

But for whatever reason that if statement just isn't doing like it seems like it should.

Is there a better way to do that if/else statement based on a param being true or false?

The debug param will either have a value of true, no value, or a value of false (as far as the URL goes).

5 Answers

how about this?

params[:debug].to_s.downcase == 'true'
Related