Ruby on rails, multiple check for nil attributes

Viewed 5779

I'm trying to check multiple attributes for nil, I've found this post simplify... but I'm not getting the results I want. I have a user whom I want to update their profile if needed. This user however has all the data I want.

  @user.try(:age_id).nil?
    #returns false
  @user.try(:customer).nil?
    #returns false
  @user.try(:country).nil? 
    #returns false

  @user.try(:age_id).try(:customer).try(:country).nil?
    #returns true

Why is it responding with true here when all the other single instances of tries responds with false?

1 Answers
Related