1

i did a git clone of a rails / solidus app, it works well on my local computer but after a deployment in Production, the CSS and JS don't work correctly. i use Rails 6, webpack and sprockets.

Requests of the asset pipeline are done but when i look the response in the DOM, responses are "404 not found" 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]

And when i try to connect to the shop, i have an error

"Can't verify CSRF token authenticity"

you can take a look with this link https://marguery.cleverapps.io/

it seems that fingerprints are wrong ? i think there is some old datas of the prior app somewhere but i don't find where and how to re-initialize it

For the first deployment i had,

ArgumentError: Missing secret_key_base for 'production' environment, set this string with rails credentials:edit

so i've remove the existing credentials.yml.enc and run: rails credentials:edit to create a new one.

the deployment was authorized.

i've tried:

i did from my locale computer. 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>' 

i did on the server side 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

my config/environnement/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

my Gemfile

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]

Any help or ideas will be greatly appreciated! Thanks

AnnABlue
  • 121
  • 3
  • 12
  • It seems to be fixed on the website you linked, isn't it? If it's solved can you post where the issue was, please? – kennyadsl Sep 14 '20 at 11:43
  • it works now, but i don't really know why... i've launch a saved version of the app on the server and it works. the only not moving part come from environnement variables that i've create and push all day long... that's still remain a Mystery. – AnnABlue Sep 15 '20 at 15:08
  • Maybe it was some caching, I saw you have bootsnap in your Gemfile. – kennyadsl Sep 16 '20 at 16:24
  • Ok, thanks, i note it! I will disable the gem for the next time. – AnnABlue Sep 18 '20 at 07:14

0 Answers0