Прежде всего, я новичок в web dev, ruby, rails heroku и т. Д., Так что простите за новость
Я развернул приложение на heroku и попытался хранить активы с использованием paperclip и s3.Я следовал рекомендациям, предоставленным https://devcenter.heroku.com/articles/paperclip-s3,, https://github.com/thoughtbot/paperclip/wiki/Paperclip-with-Amazon-S3 и https://devcenter.heroku.com/articles/direct-to-s3-image-uploads-in-rails., я использовал драгоценность figaro.Paperclip и adminsitrate хорошо работают в среде разработки (локальная корзина).
Вот 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
createaws.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 -t внизу у меня есть следующее:
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)
Проблема в том, что когда я хочу получить панель администратора (я использую gem administrator) на www.wisetax.fr/ admin Я получаю следующее:
"Извините, но что-то пошло не так Если вы владелец приложения, проверьте журналы для получения дополнительной информации."
Для получения полной информации, пожалуйста, обратите внимание, что перед тем, как решить эту проблему, я столкнулся с еще одной, которую я «исправил» (вероятно, неправильно).
Когда я выполняю команду push hero Hero, у меня прерывается rake (ресурсы для прекомпиляции rake с сообщением, относящимся к «environment»).Единственный способ, который я нашел, чтобы это исправить, это создать файл .env и добавить git этот файл (я полагаю, это грязь).Тогда я мог бы толкнуть мастера герою.
Может кто-нибудь помочь мне, пожалуйста?Большое спасибо заранее!