Q:

Heroku undefined method error in ActionView

Heroku logs shows the following error:
ActionView::Template::Error (undefined method `accepted_answer_id' for #<Question:0x000000052fd1e0>)

As background, I have a model Question, which has_many Answers.  Question also has a column accepted_answer_id.
The undefined method error is referring a line in _question.html.erb, where its used to customized the display of the answer count in a different shaded background 
  <% if question.answers.count > 0 %> 

    <% if question.accepted_answer_id %>
        <div class="pickedanswer">
          <h4><%= question.answers.count %></h4>
        </div>
    <% else %>
        <div class="numanswer">
          <h4><%= question.answers.count %></h4>
        </div>
    <% end %>

  <% else %>

      <div class="noanswer">
        <h4><%= question.answers.count%></h4>
      </div>

  <% end %>

I think the error may be raised due to the fact that initially question.accepted_answer_id is nil.. but given the way I structured the logic I do not know why it couldn't simply follow along (as it has done successfully in development).
Thanks for your help.

A:

Your schema is missing that attribute. If your code works locally, then either you added that column manually, or a migration is not in your version control.
You can see what migrations have run like so:
$ heroku run rake db:migrate:status --app app_name

This will show if any of your migrations haven't been ran. You should match those to your local migrations. Are you maybe missing one?
Running db:push will destroy your remote database and replace it with a local copy, at best. Generally you should use pgbackups:restore to do this kind of thing (https://devcenter.heroku.com/articles/heroku-postgres-import-export)

