i´m using ruby on rails and trying to check if a query is returning a value or not.
This is the query:
@search = Customer.find_by_name($login_name)
If the query finds a result, everything is fine, but how can i react on empty results?
I tried:
if @search.empty?
flash[:notice] = 'Username nicht bekannt'
redirect_to :action => :login
end
But i get an error:
undefined method `empty?' for nil:NilClass
Any Ideas what went wrong?
Thank you!!!