find_by() returns a single instance, not an array.
Movie.find_by(id:3).title will return the title of the movie with id 3. if the id doesnt exist, it returns "nil".
find() also returns a single instance, but assumes you are searching for primary key (ID).
Movie.find(3).title returns the title of movie with id 3. if id doesnt exist, it returns 404 error.
Top comments (0)