app/models/wishlist_item.rb
# Can safely return zero if user_id is unset, without it the whole object is invalid.
Can safely return zero if user_id is unset, without it the whole object is invalid.
Can safely return zero if user_id is unset without it the whole object is invalid .
def number_of_items_for_user
    if user_id
      WishlistItem.for_user(user_id).count
    else
      0
    end
  end
def number_of_items_for_user if user_id WishlistItem . for_user ( user_id ) . count else 0 end end
Can safely return zero if user_id is unset, without it the whole object is invalid.
Can safely return zero if user_id is unset without it the whole object is invalid .