首先,我是web dev,ruby,rails heroku等的新手 . 所以请原谅新手

我在heroku上部署了一个应用程序,并尝试使用paperclip和s3存储资产 . 我遵循了https://devcenter.heroku.com/articles/paperclip-s3https://github.com/thoughtbot/paperclip/wiki/Paperclip-with-Amazon-S3https://devcenter.heroku.com/articles/direct-to-s3-image-uploads-in-rails提供的指导原则 . 我使用了figaro宝石 . Paperclip和adminsitrate在开发环境(本地bin)上运行良好 .

这是我的应用程序的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.1.6'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# 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', '~> 4.0'
  # Use ActiveModel has_secure_password
  # gem 'bcrypt', '~> 3.1.7'

 # Use Capistrano for deployment
 # gem 'capistrano-rails', group: :development

 #Use materializecss as css framework
gem 'materializecss'
gem 'materialize-sass'


#Use material icons
gem 'material_icons'


#Use administrate gem as administration system
gem 'administrate', '~> 0.9.0'

#Administration system security gem
gem 'dotenv-rails', groups: [:development, :production, :test]


#Gestion des utilisateurs
gem 'devise'


#Paperclip to upload file and images
gem "paperclip", "~> 6.0.0"


#Amazon S3 pour storage
 gem 'aws-sdk', '~> 2'

#Acces and management of environment variables
gem 'figaro'



group :development, :test do
 # Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'

 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', '< 3.2'
 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
 gem 'spring'
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]

#RUBY VERSION
ruby "2.5.0"

我设置了heroku配置:

=== quiet-everglades-81710 Config Vars
AWS_ACCES_KEY_ID:         [THEKEYID]
AWS_REGION:               eu-west-2
AWS_SECRET_ACCESS_KEY:    [hesecretaccesskey]
DATABASE_URL:             postgres://rpjpypsi...@ec2…..compute-1.amazonaws.com:5432/…...
LANG:                     en_US.UTF-8
RACK_ENV:                 production
RAILS_ENV:                production
RAILS_LOG_TO_STDOUT:      enabled
RAILS_SERVE_STATIC_FILES: enabled
S3_BUCKET:                wisetax
S3_BUCKET_NAME:           wisetax
SECRET_KEY_BASE:          xxxxxxxxxxxxxxxxxxxxxx

像这样创建aws.rb:

access_key_id: AWS_ACCESS_KEY_ID
 secret_access_key: AWS_SECRET_KEY_ID

config production.rb是这样的:

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# Code is not reloaded between requests.
config.cache_classes = true

# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true

# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local       = false
config.action_controller.perform_caching = true

# Attempt to read encrypted secrets from `config/secrets.yml.enc`.
# Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
# `config/secrets.yml.key`.
config.read_encrypted_secrets = true

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
 config.public_file_server.enabled =    ENV[RAILS_SERVE_STATIC_FILES'].present?

# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass

# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false

# `config.assets.precompile` and `config.assets.version` have moved to     config/initializers/assets.rb

# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'

# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX

# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
# config.action_cable.url = 'wss://example.com/cable'
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true

# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug

# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]

# Use a different cache store in production.
# config.cache_store = :mem_cache_store

# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter     = :resque
# config.active_job.queue_name_prefix = "Wisetax_#{Rails.env}"
config.action_mailer.perform_caching = false

# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true

# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify

# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new

# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')

if ENV["RAILS_LOG_TO_STDOUT"].present?
logger           = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger    = ActiveSupport::TaggedLogging.new(logger)
end

# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false

# Paperclip et AWS S3
config.paperclip_defaults = {
  storage: :s3,
  s3_credentials: {
    bucket: ENV.fetch('S3_BUCKET_NAME'),
    access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
    secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
    s3_region: ENV.fetch('AWS_REGION'),
  }
}

end

在heroku日志中,我在底部有以下内容:

2018-06-05T15:08:30.157530+00:00 heroku[router]: at=info method=GET     path="/admin" host=www.wisetax.fr request_id=3b81377e-d179-4f97-9d21-6bed62b8cb87 fwd="88.165.143.139" dyno=web.1 connect=1ms service=242ms status=500 bytes=1827 protocol=http

我添加并配置application.yml(对于figaro)

The problem is that when I want to get my admin dashboard (I use the gem administrate) on www.wisetax.fr/admin I get the followings:

"We're sorry, but something went wrong If you are the application owner check the logs for more information."

有关完整信息,请注意在发布此问题之前,我遇到了另一个我“修复”(可能不正确)的问题 .

当我git推送heroku master时,我已经中止了rake(rake precompile assets w / messge指的是“环境”) . 我发现修复它的唯一方法是创建一个.env文件并git添加这个文件(我猜它很脏) . 然后我可以推动heroku大师 .

有人可以帮帮我吗?提前谢谢了!