views:

60

answers:

2

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 exist
:             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
A: 

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

picardo
+1  A: 

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
Alfred Nerstu