ActiveRecord not finding a record


does anybody know why this would happen:

$ sudo -i foreman-rake console
Loading production environment (Rails 5.2.1)
irb(main):001:0> Host.find_by_certname( "display2.whanganui.tasman.lan")
=> nil
irb(main):002:0> Host.find_by_name("display2.whanganui.tasman.lan").certname
=> "display2.whanganui.tasman.lan"

Shouldn’t this be
Host.find_by certname: "display......"
And i guess it can only work if certname is an actual database field?

1 Like

certname is a database field, but host has an accessor that falls back to name if certname is missing:

If you want to verify if the field is set in the db you can run: