3

I've created a new Projects model for my application and everything works fine in development but in production on Heroku I receive a 500 error. The error is coming from my ProjectsController#create the error states:

2014-05-16T07:00:48.018827+00:00 app[web.1]:
2014-05-16T07:00:48.018832+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG:
:UndefinedColumn: ERROR:  column "taggings_count" does not exist
2014-05-16T07:00:48.018834+00:00 app[web.1]: LINE 1: UPDATE "tags" SET "taggings
_count" = COALESCE("taggings_coun...
2014-05-16T07:00:48.018835+00:00 app[web.1]:

Which is almost the exact same error as the one in this issue that I found after some searching: https://github.com/KatanaCode/blogit/issues/57. This person said they solved it by pulling these new migrations from acts_as_taggable https://github.com/mbleigh/acts-as-taggable-on/tree/master/db/migrate

I'm fairly certain that I have the same problem but I'm new to rails and not sure what he means by he pulled those migrations. Do I just update my acts_as_taggable gem and push to heroku? Can someone point me in the right direction? Thanks in advance.

iamdhunt
  • 443
  • 6
  • 16

3 Answers3

2

Since you're new (welcome btw!!!), here's your error:

ActiveRecord::StatementInvalid (PG::UndefinedColumn: ERROR:  column "taggings_count" does not exist

This is a standard error, basically meaning you don't have that column in your db

Your acts_as_taggable is looking for the taggings_count column in your production db, and it's not there. A simple fix is to use the rake db:migrate method in your production environment (Heroku):

$ heroku run rake db:migrate RAILS_ENV=production

This wil run the migrate method on your heroku instance, which should populate the db for you. This is exclusive of any bugs/errors acts-as-taggable may have


Error

In regards to the specifics of your error, the link you gave basically says the newest version of acts-as-taggable has introduced several migrations, which your app will not have included

The way to fix they recommended was to take the migration files as defined here, and put them into their db/migrate directory -- allowing you to populate your db correctly

If you need help with this (after trying rake db:migrate), comment & I'll give you some more info

Richard Peck
  • 76,116
  • 9
  • 93
  • 147
  • I've tried migrating multiple times and it's still throwing the error. Could you give me more info on the other fix. Thanks – iamdhunt May 17 '14 at 21:58
0

This problem seems to only occur when the model attribute is called 'tags', it causing some sort of conflict but only in production. Dropping the column and creating a new one with a different name worked for me.

iamdhunt
  • 443
  • 6
  • 16
0

You can just rollback and migrate again:

heroku run rake db:rollback STEP=5
heroku run rake db:migrate

STEP=5 because acts_as_taggable creates 5 migrations

John
  • 1