我有一个在本地工作得很好的rails应用程序,但是当我在heroku上推送它时显示"应用程序错误" a link
我尝试访问heroku应用程序日志,但没有任何东西,但当我尝试运行heroko控制台时,它开始给出这个错误:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.2'
# Use sqlite3 as the database for Active Record
group :production do
gem 'pg', '0.18.1'
gem 'rails_12factor'
end
group :development, :test do
gem 'sqlite3'
gem 'byebug'
end
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
我的Gemfile
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# 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:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
我的Database.yml
getChildren().add(browser);
答案 0 :(得分:1)
您正在使用此代码将sqlite设置为默认数据库
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
所以使用这段代码,它被设置为sqlite,因为你包含了defualt值,这对于heroku不起作用,因为你不能在heroku上使用sqlite。
production:
<<: *default
database: db/production.sqlite3
您应该更改database.yml文件中的生产数据库值。
production:
adapter: postgresql
pool: 5
timeout: 5000
database: app_name
答案 1 :(得分:0)
在您的database.yml文件中,将生产数据库更改为使用postgresql,因为heroku不支持sqlite3。
例如:
production:
database: example_production
adapter: postgresql
host: localhost
password: