首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Rails Heroku部署上的未初始化常量CarrierWave (NameError)

Rails Heroku部署上的未初始化常量CarrierWave (NameError)
EN

Stack Overflow用户
提问于 2017-07-11 15:33:36
回答 1查看 489关注 0票数 2

我正在尝试将一个应用程序从一个cloud9 Rails实例部署到Heroku。Deploy成功完成,但应用程序在启动时崩溃。此外,未能加载Heroku rails控制台-请参见下面的错误。我是R的新手。

在进行安装之前,我在本地box和cloud9上遇到了imagemagick问题。不知道如何在Heroku实例上完成这一任务,如果这真的是我的问题。欢迎你的想法,建议,问题。

代码语言:javascript
运行
复制
$ heroku run rails console
Running rails console on ⬢ bttttt-xxxxxxxs-888888... up, run.9920 (Free)
/app/app/uploaders/image_uploader.rb:1:in `<top (required)>': uninitialized constant CarrierWave (NameError)
    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.4/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.4/lib/active_support/concurrency/share_lock.rb:150:in `exclusive'
    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.4/lib/active_support/dependencies/interlock.rb:11:in `loading'
    from /app/app/models/restaurant.rb:2:in `<class:Restaurant>'
    from /app/app/models/restaurant.rb:1:in `<top (required)>'
    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.4/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.4/lib/active_support/concurrency/share_lock.rb:150:in `exclusive'
    from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.4/lib/active_support/dependencies/interlock.rb:11:in `loading'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.4/lib/rails/engine.rb:476:in `block (2 levels) in eager_load!'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.4/lib/rails/engine.rb:475:in `each'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.4/lib/rails/engine.rb:475:in `block in eager_load!'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.4/lib/rails/engine.rb:473:in `each'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.4/lib/rails/engine.rb:473:in `eager_load!'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.4/lib/rails/engine.rb:354:in `eager_load!'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.4/lib/rails/application/finisher.rb:59:in `each'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.4/lib/rails/application/finisher.rb:59:in `block in <module:Finisher>'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.4/lib/rails/initializable.rb:30:in `instance_exec'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.4/lib/rails/initializable.rb:30:in `run'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.4/lib/rails/initializable.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 tsort_each'
    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
    from /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/tsort.rb:349:in `block in each_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_strongly_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.4/lib/rails/initializable.rb:54:in `run_initializers'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.4/lib/rails/application.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.4/lib/rails/application.rb:328:in `require'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.4/lib/rails/application.rb:328:in `require_environment!'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.4/lib/rails/commands/commands_tasks.rb:157:in `require_application_and_environment!'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.4/lib/rails/commands/commands_tasks.rb:77:in `console'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.4/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
    from /app/vendor/bundle/ruby/2.3.0/gems/railties-5.0.4/lib/rails/commands.rb:18:in `<top (required)>'
    from /app/bin/rails:9:in `require'
    from /app/bin/rails:9:in `<main>'

Gemfile代码-

代码语言:javascript
运行
复制
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.1'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
# 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
  gem 'sqlite3'
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'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'carrierwave'
  gem 'mini_magick'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

group :production do
  gem 'pg', '0.20.0'
end
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-07-11 17:06:25

未初始化常数CarrierWave (NameError)

您已经将gem 'carrierwave'置于group :development之下,这样gem 就不会被捆绑在生产中。这就是错误的原因。

解决方案:

将它移出 development

代码语言:javascript
运行
复制
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.1'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
# 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'
gem 'carrierwave'
# 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
  gem 'sqlite3'
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'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'mini_magick'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

group :production do
  gem 'pg', '0.20.0'
end

将其添加到developmentproduction组中

代码语言:javascript
运行
复制
group :development, :production do
  gem 'carrierwave'
end

并最终运行bundle install

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45038884

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档