Answer the question
In order to leave comments, you need to log in
Filtering and value in Rails?
Hello. Is it possible in Rails, what if the value is not found, then what would return a null value, and not fall into an error?
count = products.find_by( date: '2017-05-16' ).count
product = products.find_by( date: '2017-05-16' )
count = product.present? ? product .count : 0
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question