2014-04-28 4 views
2

애플리케이션을 시작하기 전에 사람들이 전자 메일에 가입 할 수있는 샘플 사전 가입 페이지를 작성하고 있습니다. 내가 입력하는 경우 :Heroku에 배포 (테이블이 존재하지 않음 오류)

heroku open 

내 브라우저 내 로그를 확인한 후

We're sorry, but something went wrong. 

If you are the application owner check the logs for more information. 

에 다음과 같은 오류를 얻을, 나는이 이상한 오류를 발견 :

[36m2014-04-28T08:22:01.921791+00:00 app[web.1]:←[0m PG::UndefinedTable: ERROR: 
relation "premails" does not exist 

그게 무슨 뜻 이죠? 나는 다음과 같은 마이그레이션이 있습니다

class CreatePremails < ActiveRecord::Migration 
    def change 
    create_table :premails do |t| 

     t.text :email 

     t.timestamps 
    end 
    end 
end 

및 모델 :

class Premail < ActiveRecord::Base 

end 

내가 그에게 Heroku에 배포하기 위해 어떻게해야합니까? 그게 문제인지 아니면 아마도 내 database.yml 파일을 변경해야하는지 잘 모르겠습니다. 현재 내가 거기에있다 :

# SQLite version 3.x 
# gem install sqlite3 
# 
# Ensure the SQLite 3 gem is defined in your Gemfile 
# gem 'sqlite3' 
development: 
    adapter: sqlite3 
    database: db/development.sqlite3 
    pool: 5 
    timeout: 5000 

# Warning: The database defined as "test" will be erased and 
# re-generated from your development database when you run "rake". 
# Do not set this db to the same as development or production. 
test: 
    adapter: sqlite3 
    database: db/test.sqlite3 
    pool: 5 
    timeout: 5000 

production: 
    adapter: sqlite3 
    database: db/production.sqlite3 
    pool: 5 
    timeout: 5000 

Heroku는 pg에서만 작동하므로 어쩌면 변경해야 할 필요가 있을까요? Windows8 64

source 'https://rubygems.org' 


gem 'pg' 

gem 'bootstrap-sass', '~> 3.1.1' 

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 
gem 'rails', '4.0.3' 

# Use SCSS for stylesheets 
gem 'sass-rails', '~> 4.0.0' 

# Use Uglifier as compressor for JavaScript assets 
gem 'uglifier', '>= 1.3.0' 

# Use CoffeeScript for .js.coffee assets and views 
gem 'coffee-rails', '~> 4.0.0' 

# See https://github.com/sstephenson/execjs#readme for more supported runtimes 
# gem 'therubyracer', platforms: :ruby 

# Use jquery as the JavaScript library 
gem 'jquery-rails' 

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks 
gem 'turbolinks' 

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 
gem 'jbuilder', '~> 1.2' 

group :doc do 
    # bundle exec rake doc:rails generates the API under doc/api. 
    gem 'sdoc', require: false 
end 

group :production do 
    gem 'rails_12factor', '0.0.2' 
end 

내가

감사 :

몇 가지 추가 정보는 여기 내 Gemfile입니다!

+0

'heroku run rake db : migrate'을 실행 했습니까? –

+1

그랬어! 젠장, 그렇게 간단 해! – user3408293

+0

니스! 나는 문제가 어디에 서 있었는지를 설명하는 답을 썼다. –

답변

5

몇 가지 문제 :

  1. You've not set a "real" production database
  2. You've not used rake db:migrate in production

첫째, 당신은 create a production db to run on Heroku해야합니다. Heroku는 당신을 위해 어떤 DB도 호스팅하지 않습니다 - 아마존 EC2 스택에서만 실행됩니다; 의미 당신은 단지에 채워 모든 테이블을 얻을 수 있도록 명령 줄에서 heroku run rake db:migrate를 실행해야합니다, 당신의 자신의 DB 서버를 prodivde, 또는 프로덕션 데이터베이스를 설정 한 후 Heroku가의 postgres 인스턴스

을 중 하나를 사용하거나이 db 서버는 오류를 해결해야합니다