ActiveModel::UnknownAttributeError

So I keep getting this error message in production ActiveModel::UnknownAttributeError: unknown attribute ‘started’ for Completion. The ‘started’ column was added in a later migration on the completions table. The schema.rb file shows as this column exists on the completions table and the migration that added that column shows as up. I’ve done some further research but I’m still lost as to why this is occurring. Thank you in advance for any and all help around this.

That’s great but have you actually confirmed through logging into the DB via console that the field is there? Can you run queries against it via console?

Yeah, I can get into the console and make new records, update the started attribute for a record and this query works as well Completion.where(started: false).limit(5)

OK, good. Are you running multiple servers? Are you running background jobs?

yes to both of those questions.

So are the errors coming from one particular system, or all?

Are you doing any caching? If you cache an ActiveRecord object you could see errors like this.

Also, just to be on the safe side, have you confirmed that you’ve restarted all processes (sidekiq, web etc)?

Thanks for the ideas Adam! I’m looking into all of this now that I’m back to work. I’ll report back my findings.

So I’m happy to report that after the code had a nice extended American holiday break, that magically it seemingly updated itself to now know about the previously unknown attribute on the db column. Still not sure what the exact issue was but from what I can gather, it was most likely a caching of the db schema lthat needed to get blown away or services that need a restart. I can’t thank you all enough for all the guidance and insight provided on this issue. I owe the community one for sure!!!

1 Like