jeudi 19 janvier 2017

Testing for nil value returned where query

I'm doing a query like this:

sla_field = CustomValue.where(:custom_field_id =>
  sla_field_id.id,:customized_id => params[:project_id])

And it's find when there are values, but if no value is present, where returns object that looks like this []

And if I try to test it like

sla_field.empty or sla_field.nil I get errors, how do I figure out did where query return something or not?

Aucun commentaire:

Enregistrer un commentaire