If I attempt to fetch a record from the db like:
@user = User.find_by_user_name("blah")
How do I check if the value was null? i.e. the record was found?
And should I use and or && as they seem to be different?
if @user and @user.age > 0
....
end
should be suffice to check if the value was not nil.
And the difference between && and ‘and’ is that && has a higher precedence over ‘and’. See here