friendly_uuid
friendly_uuid copied to clipboard
MyModel.find(nil) does not raise ActiveRecord::RecordNotFound
TLDR: MyModel.find(nil)
should throw ActiveRecord::RecordNotFound
.
What happened:
While doing ClientProject.find(params[:id])
the system returned with a random record
.
Baffled by the result I realised it was simply not throwing an error as internally was instead doing this:
SELECT "client_projects".* FROM "client_projects" WHERE (LEFT(client_projects.id::text, 0) = '') ORDER BY "client_projects"."created_at" ASC LIMIT $1 [["LIMIT", 1]]
SELECT "client_projects".* FROM "client_projects" WHERE "client_projects"."id" = $1 LIMIT $2 [["id", "ae7aef7a-..."], ["LIMIT", 1]]
Which lead to realise I had params[:id] == nil
.
Nice find and diagnosis! Not much in the way of time recently but Will happily accept a PR.
Hi @glacials and @saxxi: I'll take a stab at this if you don't mind. Please go ahead and assign me.