【发布时间】:2014-06-13 17:00:29
【问题描述】:
我正在构建一个示例预注册页面,人们可以在其中在应用程序启动之前注册他们的电子邮件。当我输入时:
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,也许我需要在那里进行更改?
一些附加信息,这是我的 Gemfile:
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
我在 Windows8 64 上
谢谢!
【问题讨论】:
-
你跑过
heroku run rake db:migrate吗? -
做到了!太简单了!
-
不错!我写了一个答案来描述问题可能所在的位置
-
我才刚学几个月。我只有一个 Windows,所以也有.. 一开始遇到问题,但后来你开始学习 Windows 的小复杂性。一旦我变得更高级,我可能会在某个时候运行 Linux。
-
如果您知道如何解决,请告诉我,谢谢!
标签: ruby-on-rails database heroku ruby-on-rails-4