1

I'm getting a database error in production. But in development no error.

ActiveModel::MissingAttributeError (can't write unknown attribute `invited_by_id`):

invited_by_id is a column added by the Devise Invitable gem to my User table. I encountered this error after pushing my Devise Invitable implementation to production for the first time and then attempting to invite a new user.

I have confirmed that invited_by_id IS present in both my development and production tables. I have checked this multiple times via Rails console for each environment. I have also done rake db:migrate twice for good measure (in production) with the first time adding the Devise Invitable columns and the second time, of course, having no new migrations to run since the columns were already added. There are also numerous other columns added by Devise Invitable to the same User table that were successfully migrated and are not creating errors. I have successfully edited one as well. (Google Searches, Devise Invitable Github issues, and a thorough review of my development and production environment fields have yielded nothing but encouragement to check that the column is present -- which it is.)

Is there something to be aware of with Devise Invitable, User tables, or with development versus production databases for a situation like this? For some additional context, I am using Devise Invitable 1.5.5, Rails 4.2.4, and my production database is on Heroku.

Thank you!

K M Rakibul Islam
  • 31,427
  • 11
  • 79
  • 100
supertext
  • 222
  • 1
  • 12

1 Answers1

1
ActiveModel::MissingAttributeError (can't write unknown attribute `invited_by_id`)

Looking at this error message, you are missing invited_by_id column in your production database. Make sure you run your migrations on production environment and try again. That should fix your problem.

Here is the same issue reported on the gem's github page.

You can also try restarting your heroku app which seems to fix this type of issues many times :)

K M Rakibul Islam
  • 31,427
  • 11
  • 79
  • 100