1

我做了一个 rails / solidus 应用程序的 git 克隆,它在我的本地计算机上运行良好,但在生产中部署后,CSS 和 JS 无法正常工作。我使用 Rails 6、webpack 和 sprockets。

资产管道的请求已完成,但当我查看 DOM 中的响应时,响应为“404 未找到” GEThttps://marguery.cleverapps.io/assets/application-b31b32abb971f17a524d21ec2a0da1c8e278eeec1494078c645d0b78c1421333.css[HTTP/1.1 404 Not Found 131ms]

GEThttps://marguery.cleverapps.io/packs/js/application-8a33c36bccf807dbd76b.js[HTTP/1.1 404 Not Found 320ms]

当我尝试连接到商店时,出现错误

"Can't verify CSRF token authenticity"

您可以通过此链接查看 https://marguery.cleverapps.io/

指纹好像不对?我认为某处存在先前应用程序的一些旧数据,但我不知道在哪里以及如何重新初始化它

对于我的第一次部署,

ArgumentError:缺少secret_key_base“生产”环境,将此字符串设置为rails credentials:edit

所以我删除了现有的 credentials.yml.enc 并运行:rails credentials:edit创建一个新的。

部署已获授权。

我试过了:

我是从我的语言环境计算机上做的。 RAILS_ENV=production rails assets:precompile

ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
/mnt/882A716B2A7156E2/0-Projets/maisonmarguery2/maisonmarguery/config/environment.rb:5:in `<main>'
/mnt/882A716B2A7156E2/0-Projets/maisonmarguery2/maisonmarguery/bin/rails:9:in `<top (required)>'
/mnt/882A716B2A7156E2/0-Projets/maisonmarguery2/maisonmarguery/bin/spring:15:in `<top (required)>'
./bin/rails:3:in `load'
./bin/rails:3:in `<main>' 

我在服务器端做了 rails assets:precompile

yarn install v1.22.4
[1/4] Resolving packages...
success Already up-to-date.
Done in 1.00s.
Everything's up-to-date. Nothing to do

我的配置/环境/production.rb

Rails.application.configure do
  
  config.cache_classes = true

  
  config.eager_load = true

  
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  
  config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

  # Compress CSS using a preprocessor.
  config.assets.css_compressor = :sass

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

 

  # 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

  # Store uploaded files on the local file system (see config/storage.yml for options).
  config.active_storage.service = :local

  
  config.log_level = :debug

  
  config.log_tags = [ :request_id ]

  

  config.action_mailer.perform_caching = false

  
  config.active_support.deprecation = :notify

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


  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

 
end

我的宝石文件

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.6.5'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.2'
# Use sqlite3 as the database for Active Record
gem 'railties', '>= 5.1'
gem 'sqlite3', '~> 1.4'
gem 'pg'
gem 'open_solidus_cloudinary', git: 'https://github.com/Berlimioz/open_solidus_cloudinary.git'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Use SCSS for stylesheets
gem 'sassc-rails'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.0'
# 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.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'autoprefixer-rails'
gem 'font-awesome-sass', '~> 5.6.1'
gem 'simple_form'
gem 'cloudinary', '~> 1.1.7'
gem 'google-analytics-rails', '~> 1.1', '>= 1.1.1'
gem 'sitemap_generator'

gem 'solidus'
gem 'solidus_auth_devise'

gem 'solidus_i18n', '~> 2.0'
gem 'rails-i18n', '> 5.0'
gem 'kaminari-i18n', '~> 0.5.0'
gem 'routing-filter', '~> 0.6.0'
gem 'sprockets', '= 3.7.2'
gem 'dotenv-rails'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

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]

end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 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'
  gem 'guard-livereload', '~> 2.5', require: false
  gem 'rack-livereload'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
end

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

任何帮助或想法将不胜感激!谢谢

4

0 回答 0