I' following the Ruby on Rails Tutorial. After I created an user, i destroyed it with destroy
method, then i use find
to check if it still exist, my console return exactly like the tutorial, but with some errors.
This is error image:
Here i created a user called "abc" with id: 7, then i destroyed and use User.find(7)
to find user.
I installed rails with rvm and created gemset named 1.9.3@rails3tutorial2endEd. I searched but don't know what this is problem, can anybody help? Thanks so much.
That's normal. Since the record does not exist anymore, you would get ActiveRecord::RecordNotFound
If you wanted to return nil
instead. You could try something like
User.where(:id => 51).exists?
which will return true
or false.