2017-04-15 205 views
-2

在本地,但没有工作,我有一个的工作完全罚款在当地一个Rails应用程序,但是当我推它在Heroku它显示“应用程序错误” enter image description hereRails应用在生产

我试图访问Heroku的应用程序日志,但没有什么在那里,但是当我试图heroko上运行控制台它开始给这个错误:

C:\Sites\bbb>heroku run rails console 
This is the legacy Heroku CLI. Please install the new CLI from https://cli.herok 
u.com 
Running rails console on hidden-hollows-63773... up, run.4100 (Free) 
/app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connecti 
on_adapters/connection_specification.rb:176:in `rescue in spec': Specified 'sqli 
te3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to you 
r Gemfile (and ensure its version is at the minimum required by ActiveRecord). (
Gem::LoadError) 
     from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_re 
cord/connection_adapters/connection_specification.rb:173:in `spec' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_re 
cord/connection_handling.rb:53:in `establish_connection' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_re 
cord/railtie.rb:125:in `block (2 levels) in <class:Railtie>' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/lazy_load_hooks.rb:43:in `instance_eval' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/lazy_load_hooks.rb:43:in `execute_hook' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/lazy_load_hooks.rb:50:in `block in run_load_hooks' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/lazy_load_hooks.rb:49:in `each' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/lazy_load_hooks.rb:49:in `run_load_hooks' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_re 
cord/base.rb:324:in `<module:ActiveRecord>' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_re 
cord/base.rb:24:in `<top (required)>' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/dependencies.rb:293:in `require' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/dependencies.rb:293:in `block in require' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/dependencies.rb:259:in `load_dependency' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/dependencies.rb:293:in `require' 
     from /app/app/models/application_record.rb:1:in `<top (required)>' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/dependencies.rb:293:in `require' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/dependencies.rb:293:in `block in require' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/dependencies.rb:259:in `load_dependency' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/dependencies.rb:293:in `require' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/dependencies.rb:380:in `block in require_or_load' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/dependencies.rb:37:in `block in load_interlock' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/dependencies/interlock.rb:12:in `block in loading' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/concurrency/share_lock.rb:150:in `exclusive' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/dependencies/interlock.rb:11:in `loading' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/dependencies.rb:37:in `load_interlock' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/dependencies.rb:358:in `require_or_load' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/dependencies.rb:336:in `depend_on' 
     from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_s 
upport/dependencies.rb:252:in `require_dependency' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/engine. 
rb:476:in `block (2 levels) in eager_load!' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/engine. 
rb:475:in `each' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/engine. 
rb:475:in `block in eager_load!' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/engine. 
rb:473:in `each' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/engine. 
rb:473:in `eager_load!' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/engine. 
rb:354:in `eager_load!' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/applica 
tion/finisher.rb:59:in `each' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/applica 
tion/finisher.rb:59:in `block in <module:Finisher>' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/initial 
izable.rb:30:in `instance_exec' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/initial 
izable.rb:30:in `run' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/initial 
izable.rb:55:in `block in run_initializers' 
     from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:228:in `block in tso 
rt_each' 
     from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:350:in `block (2 lev 
els) in each_strongly_connected_component' 
     from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:431:in `each_strongl 
y_connected_component_from' 
     from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:349:in `block in eac 
h_strongly_connected_component' 
     from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:347:in `each' 
     from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:347:in `call' 
     from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:347:in `each_strongl 
y_connected_component' 
     from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each' 
     from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/initial 
izable.rb:54:in `run_initializers' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/applica 
tion.rb:352:in `initialize!' 
     from /app/config/environment.rb:5:in `<top (required)>' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/applica 
tion.rb:328:in `require' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/applica 
tion.rb:328:in `require_environment!' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/command 
s/commands_tasks.rb:157:in `require_application_and_environment!' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/command 
s/commands_tasks.rb:77:in `console' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/command 
s/commands_tasks.rb:49:in `run_command!' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/command 
s.rb:18:in `<top (required)>' 
     from /app/bin/rails:4:in `require' 
     from /app/bin/rails:4:in `<main>' 

我的Gemfile

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] 

我的database.yml

# 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 
+1

根据gem文件,sqlite gem不会在生产环境中加载,只能进行测试和开发。将宝石添加到生产中。 – dbugger

+2

为什么你首先使用不同的数据库进行生产和开发? – RSB

回答

0

在您的database.yml文件,改变生产数据库使用PostgreSQL作为Heroku的不支持sqlite3的。

例如:

production: 
    database: example_production 
    adapter: postgresql 
    host: localhost 
    password: 
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