Suppose we have a Student with id=”4”. If we delete the Student with id=”4”, what will be the result of the following queries:
Student.find(4)
Student.find_by_id(4)
Student.find(4)
will raise an error: ActiveRecord::RecordNotFound: Couldn't find Student with id=4
Student.find_by_id(4)
will return nil
and will not raise an error.
Comments
Post a Comment