开发者

Heroku Postgresql error

I deployed an app that uses ActiveRecord to Heroku, and I got an internal server error. It works fine on my local machine (where the database is SQLite). Below is the log message for the error. The newsletters table is just a table with no associations. It's got just one field for email addresses. I don't know PostgreSQL, and I'm not sure what the problem is with this.

"ActiveRecord::StatementInvalid - PGError: ERROR:  relation "newsletters" does not ex开发者_如何学运维ist
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
              FROM pg_attribute a LEFT JOIN pg_attrdef d
                ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE a.attrelid = '"newsletters"'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum
:

This is the code that gets called when the error appears.

  post :index, :map => "/newsletter" do
    email=params[:email]
    @signup=Newsletter.new(:email=>email)
    render "newsletter/index",:layout => false
  end


I think Heroku will find your local database so you just have to write:

heroku db:push

And if you want to fetch data from the server:

heroku db:pull


I fixed my problem. All I had to was heroku db:push sqlite://db/local.db


The root of this problem is that ActiveRecord is trying to understand the structure of a given table through something called a "catalog query." This is a query against the database's metadata relations to understand what is going on in there.

This query assumes the relation already exists, and because it did not, it blew up with a cryptic message. This is probably falls into the region of "report this to ActiveRecord" (if not already fixed) as sub-ideal error messaging in a somewhat common failure case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜