I
I
IvanN7772014-10-10 14:02:26
Ruby on Rails
IvanN777, 2014-10-10 14:02:26

How to check if parameters are empty in rails?

Tried to check like this

p=params.require(:recovery_password).permit(:email)
if p.nil?

However, just before the check, the application crashes with an error that the parameter is empty, on the first line of the example above.
How to check that?
I know it's a simple question, but I can't find it. What matters is how to do it right.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vsuhachev, 2014-10-10
@IvanN777

if p.blank?

H
Heafy, 2014-10-10
@Heafy

foo = bar if bar
or
if defined?(bar)
foo = bar

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question