Javascript assets not loading to deployed Heroku app(Production), but works fine locally











up vote
0
down vote

favorite












I have been fighting with this issue for the past two days now and have gotten nowhere, unfortunately. I know this is a regularly asked question but none of the answers I have encountered have helped.



Below shows my assets in Chrome when the application is run locally.



Assets in Chrome(local)



Below are assets in Chrome Production



Assets in Chrome(production)



What I have tried



I have tried doing config.assets.compile = true



I tried reorganizing my application.js file



also RAILS_ENV=production bin/rails assets:precompile and then deployed to production.



I honestly wish I could remember all the steps i have tried but the ones above are the most reoccurring.



Code



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.0.6'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.18'
# 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'
gem 'jquery-ui-rails'
# 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
gem 'rubocop', require: false


group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
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 '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 :development, :test do
gem 'rspec-rails', '~> 3.5'
gem "factory_bot_rails"
gem 'database_cleaner'
end


group :production do
gem 'mini_racer'
end

gem 'devise'
gem 'bootstrap', '4.0.0.alpha6'

gem "awesome_print", require:"ap"
gem 'simple_form'
gem 'jquery-ui-rails'
gem 'gon'
gem 'sprockets', '~>3.7.2'
gem 'rails-assets-tether', '>= 1.1.0'


application.js



//
//= require jquery
//= require "tether"
//= require jquery-ui
//= require bootstrap
//= require_tree .
//= require bootstrap-sprockets


application.rb



require_relative 'boot'

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module Chessapp
class Application < Rails::Application
config.serve_static_assets = true
config.assets.compile = true
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
end
end


production.rb



Rails.application.configure do
#config.action_mailer.default_url_options = { host: 'chesschessrevolution.herokuapp.com' }

# 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
config.serve_static_assets = 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.new(harmony: true)
# config.assets.css_compressor = :sass

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

# `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 = "chessapp_#{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')

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

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


application.html.erb



<!DOCTYPE html>
<html>
<head>
<title>Chessapp</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': true %>
<link href="https://fonts.googleapis.com/css?family=Audiowide" rel="stylesheet">
</head>
<body>
<%= render 'shared/nav' %>
<div>
<% flash.each do |key, value| %>
<div class="alert alert-<%= key %>"><%= value %></div>
<% end %>
<class="notice"><%= notice %></p>
<class="alert"><%= alert %></p>

<%= yield %>

</div>
</body>
</html>


Any help on this would be greatly appreciated. If the information I provided isn't sufficient please feel free to check out the repository @ github .










share|improve this question




























    up vote
    0
    down vote

    favorite












    I have been fighting with this issue for the past two days now and have gotten nowhere, unfortunately. I know this is a regularly asked question but none of the answers I have encountered have helped.



    Below shows my assets in Chrome when the application is run locally.



    Assets in Chrome(local)



    Below are assets in Chrome Production



    Assets in Chrome(production)



    What I have tried



    I have tried doing config.assets.compile = true



    I tried reorganizing my application.js file



    also RAILS_ENV=production bin/rails assets:precompile and then deployed to production.



    I honestly wish I could remember all the steps i have tried but the ones above are the most reoccurring.



    Code



    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.0.6'
    # Use postgresql as the database for Active Record
    gem 'pg', '~> 0.18'
    # 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'
    gem 'jquery-ui-rails'
    # 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
    gem 'rubocop', require: false


    group :development, :test do
    # Call 'byebug' anywhere in the code to stop execution and get a debugger console
    gem 'byebug', platform: :mri
    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 '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 :development, :test do
    gem 'rspec-rails', '~> 3.5'
    gem "factory_bot_rails"
    gem 'database_cleaner'
    end


    group :production do
    gem 'mini_racer'
    end

    gem 'devise'
    gem 'bootstrap', '4.0.0.alpha6'

    gem "awesome_print", require:"ap"
    gem 'simple_form'
    gem 'jquery-ui-rails'
    gem 'gon'
    gem 'sprockets', '~>3.7.2'
    gem 'rails-assets-tether', '>= 1.1.0'


    application.js



    //
    //= require jquery
    //= require "tether"
    //= require jquery-ui
    //= require bootstrap
    //= require_tree .
    //= require bootstrap-sprockets


    application.rb



    require_relative 'boot'

    require 'rails/all'

    # Require the gems listed in Gemfile, including any gems
    # you've limited to :test, :development, or :production.
    Bundler.require(*Rails.groups)

    module Chessapp
    class Application < Rails::Application
    config.serve_static_assets = true
    config.assets.compile = true
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.
    end
    end


    production.rb



    Rails.application.configure do
    #config.action_mailer.default_url_options = { host: 'chesschessrevolution.herokuapp.com' }

    # 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
    config.serve_static_assets = 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.new(harmony: true)
    # config.assets.css_compressor = :sass

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

    # `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 = "chessapp_#{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')

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

    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


    application.html.erb



    <!DOCTYPE html>
    <html>
    <head>
    <title>Chessapp</title>
    <%= csrf_meta_tags %>
    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track': true %>
    <link href="https://fonts.googleapis.com/css?family=Audiowide" rel="stylesheet">
    </head>
    <body>
    <%= render 'shared/nav' %>
    <div>
    <% flash.each do |key, value| %>
    <div class="alert alert-<%= key %>"><%= value %></div>
    <% end %>
    <class="notice"><%= notice %></p>
    <class="alert"><%= alert %></p>

    <%= yield %>

    </div>
    </body>
    </html>


    Any help on this would be greatly appreciated. If the information I provided isn't sufficient please feel free to check out the repository @ github .










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have been fighting with this issue for the past two days now and have gotten nowhere, unfortunately. I know this is a regularly asked question but none of the answers I have encountered have helped.



      Below shows my assets in Chrome when the application is run locally.



      Assets in Chrome(local)



      Below are assets in Chrome Production



      Assets in Chrome(production)



      What I have tried



      I have tried doing config.assets.compile = true



      I tried reorganizing my application.js file



      also RAILS_ENV=production bin/rails assets:precompile and then deployed to production.



      I honestly wish I could remember all the steps i have tried but the ones above are the most reoccurring.



      Code



      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.0.6'
      # Use postgresql as the database for Active Record
      gem 'pg', '~> 0.18'
      # 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'
      gem 'jquery-ui-rails'
      # 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
      gem 'rubocop', require: false


      group :development, :test do
      # Call 'byebug' anywhere in the code to stop execution and get a debugger console
      gem 'byebug', platform: :mri
      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 '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 :development, :test do
      gem 'rspec-rails', '~> 3.5'
      gem "factory_bot_rails"
      gem 'database_cleaner'
      end


      group :production do
      gem 'mini_racer'
      end

      gem 'devise'
      gem 'bootstrap', '4.0.0.alpha6'

      gem "awesome_print", require:"ap"
      gem 'simple_form'
      gem 'jquery-ui-rails'
      gem 'gon'
      gem 'sprockets', '~>3.7.2'
      gem 'rails-assets-tether', '>= 1.1.0'


      application.js



      //
      //= require jquery
      //= require "tether"
      //= require jquery-ui
      //= require bootstrap
      //= require_tree .
      //= require bootstrap-sprockets


      application.rb



      require_relative 'boot'

      require 'rails/all'

      # Require the gems listed in Gemfile, including any gems
      # you've limited to :test, :development, or :production.
      Bundler.require(*Rails.groups)

      module Chessapp
      class Application < Rails::Application
      config.serve_static_assets = true
      config.assets.compile = true
      # Settings in config/environments/* take precedence over those specified here.
      # Application configuration should go into files in config/initializers
      # -- all .rb files in that directory are automatically loaded.
      end
      end


      production.rb



      Rails.application.configure do
      #config.action_mailer.default_url_options = { host: 'chesschessrevolution.herokuapp.com' }

      # 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
      config.serve_static_assets = 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.new(harmony: true)
      # config.assets.css_compressor = :sass

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

      # `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 = "chessapp_#{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')

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

      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


      application.html.erb



      <!DOCTYPE html>
      <html>
      <head>
      <title>Chessapp</title>
      <%= csrf_meta_tags %>
      <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
      <%= javascript_include_tag 'application', 'data-turbolinks-track': true %>
      <link href="https://fonts.googleapis.com/css?family=Audiowide" rel="stylesheet">
      </head>
      <body>
      <%= render 'shared/nav' %>
      <div>
      <% flash.each do |key, value| %>
      <div class="alert alert-<%= key %>"><%= value %></div>
      <% end %>
      <class="notice"><%= notice %></p>
      <class="alert"><%= alert %></p>

      <%= yield %>

      </div>
      </body>
      </html>


      Any help on this would be greatly appreciated. If the information I provided isn't sufficient please feel free to check out the repository @ github .










      share|improve this question















      I have been fighting with this issue for the past two days now and have gotten nowhere, unfortunately. I know this is a regularly asked question but none of the answers I have encountered have helped.



      Below shows my assets in Chrome when the application is run locally.



      Assets in Chrome(local)



      Below are assets in Chrome Production



      Assets in Chrome(production)



      What I have tried



      I have tried doing config.assets.compile = true



      I tried reorganizing my application.js file



      also RAILS_ENV=production bin/rails assets:precompile and then deployed to production.



      I honestly wish I could remember all the steps i have tried but the ones above are the most reoccurring.



      Code



      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.0.6'
      # Use postgresql as the database for Active Record
      gem 'pg', '~> 0.18'
      # 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'
      gem 'jquery-ui-rails'
      # 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
      gem 'rubocop', require: false


      group :development, :test do
      # Call 'byebug' anywhere in the code to stop execution and get a debugger console
      gem 'byebug', platform: :mri
      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 '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 :development, :test do
      gem 'rspec-rails', '~> 3.5'
      gem "factory_bot_rails"
      gem 'database_cleaner'
      end


      group :production do
      gem 'mini_racer'
      end

      gem 'devise'
      gem 'bootstrap', '4.0.0.alpha6'

      gem "awesome_print", require:"ap"
      gem 'simple_form'
      gem 'jquery-ui-rails'
      gem 'gon'
      gem 'sprockets', '~>3.7.2'
      gem 'rails-assets-tether', '>= 1.1.0'


      application.js



      //
      //= require jquery
      //= require "tether"
      //= require jquery-ui
      //= require bootstrap
      //= require_tree .
      //= require bootstrap-sprockets


      application.rb



      require_relative 'boot'

      require 'rails/all'

      # Require the gems listed in Gemfile, including any gems
      # you've limited to :test, :development, or :production.
      Bundler.require(*Rails.groups)

      module Chessapp
      class Application < Rails::Application
      config.serve_static_assets = true
      config.assets.compile = true
      # Settings in config/environments/* take precedence over those specified here.
      # Application configuration should go into files in config/initializers
      # -- all .rb files in that directory are automatically loaded.
      end
      end


      production.rb



      Rails.application.configure do
      #config.action_mailer.default_url_options = { host: 'chesschessrevolution.herokuapp.com' }

      # 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
      config.serve_static_assets = 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.new(harmony: true)
      # config.assets.css_compressor = :sass

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

      # `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 = "chessapp_#{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')

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

      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


      application.html.erb



      <!DOCTYPE html>
      <html>
      <head>
      <title>Chessapp</title>
      <%= csrf_meta_tags %>
      <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
      <%= javascript_include_tag 'application', 'data-turbolinks-track': true %>
      <link href="https://fonts.googleapis.com/css?family=Audiowide" rel="stylesheet">
      </head>
      <body>
      <%= render 'shared/nav' %>
      <div>
      <% flash.each do |key, value| %>
      <div class="alert alert-<%= key %>"><%= value %></div>
      <% end %>
      <class="notice"><%= notice %></p>
      <class="alert"><%= alert %></p>

      <%= yield %>

      </div>
      </body>
      </html>


      Any help on this would be greatly appreciated. If the information I provided isn't sufficient please feel free to check out the repository @ github .







      ruby-on-rails jquery-ui heroku






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 at 0:32









      Randy Casburn

      3,9251218




      3,9251218










      asked Nov 19 at 0:20









      Jumping Jack

      73




      73
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          Assets are loading, the reason why you are not able to see them individually(separate files) in production is because rails precompiles(minimizes) all the assets and puts into a single file.



          So if you have look at your application.css and application.js which is getting rendered in production you can see that it contains bootstrap, jquery, jquery-ui etc which you've required in application.js



          I had a look at your application.css and application.js and it contained all the assets you've required. They are not available anymore probably because you have done re-deployment.



          You can learn more about asset pipeline here






          share|improve this answer























          • Thanks alot! You definitely guided me in the right direction. I looking in the compiled folder provided in chrome source and noticed my code was in fact there. What confuses me is why Javascript works one when locally and another way when in production. But I guess since I know that my code is there i will have to do some serious debugging. Thanks again.
            – Jumping Jack
            Nov 19 at 15:36











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53366823%2fjavascript-assets-not-loading-to-deployed-heroku-appproduction-but-works-fine%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote



          accepted










          Assets are loading, the reason why you are not able to see them individually(separate files) in production is because rails precompiles(minimizes) all the assets and puts into a single file.



          So if you have look at your application.css and application.js which is getting rendered in production you can see that it contains bootstrap, jquery, jquery-ui etc which you've required in application.js



          I had a look at your application.css and application.js and it contained all the assets you've required. They are not available anymore probably because you have done re-deployment.



          You can learn more about asset pipeline here






          share|improve this answer























          • Thanks alot! You definitely guided me in the right direction. I looking in the compiled folder provided in chrome source and noticed my code was in fact there. What confuses me is why Javascript works one when locally and another way when in production. But I guess since I know that my code is there i will have to do some serious debugging. Thanks again.
            – Jumping Jack
            Nov 19 at 15:36















          up vote
          0
          down vote



          accepted










          Assets are loading, the reason why you are not able to see them individually(separate files) in production is because rails precompiles(minimizes) all the assets and puts into a single file.



          So if you have look at your application.css and application.js which is getting rendered in production you can see that it contains bootstrap, jquery, jquery-ui etc which you've required in application.js



          I had a look at your application.css and application.js and it contained all the assets you've required. They are not available anymore probably because you have done re-deployment.



          You can learn more about asset pipeline here






          share|improve this answer























          • Thanks alot! You definitely guided me in the right direction. I looking in the compiled folder provided in chrome source and noticed my code was in fact there. What confuses me is why Javascript works one when locally and another way when in production. But I guess since I know that my code is there i will have to do some serious debugging. Thanks again.
            – Jumping Jack
            Nov 19 at 15:36













          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          Assets are loading, the reason why you are not able to see them individually(separate files) in production is because rails precompiles(minimizes) all the assets and puts into a single file.



          So if you have look at your application.css and application.js which is getting rendered in production you can see that it contains bootstrap, jquery, jquery-ui etc which you've required in application.js



          I had a look at your application.css and application.js and it contained all the assets you've required. They are not available anymore probably because you have done re-deployment.



          You can learn more about asset pipeline here






          share|improve this answer














          Assets are loading, the reason why you are not able to see them individually(separate files) in production is because rails precompiles(minimizes) all the assets and puts into a single file.



          So if you have look at your application.css and application.js which is getting rendered in production you can see that it contains bootstrap, jquery, jquery-ui etc which you've required in application.js



          I had a look at your application.css and application.js and it contained all the assets you've required. They are not available anymore probably because you have done re-deployment.



          You can learn more about asset pipeline here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 19 at 6:25

























          answered Nov 19 at 6:05









          eurodo061

          364




          364












          • Thanks alot! You definitely guided me in the right direction. I looking in the compiled folder provided in chrome source and noticed my code was in fact there. What confuses me is why Javascript works one when locally and another way when in production. But I guess since I know that my code is there i will have to do some serious debugging. Thanks again.
            – Jumping Jack
            Nov 19 at 15:36


















          • Thanks alot! You definitely guided me in the right direction. I looking in the compiled folder provided in chrome source and noticed my code was in fact there. What confuses me is why Javascript works one when locally and another way when in production. But I guess since I know that my code is there i will have to do some serious debugging. Thanks again.
            – Jumping Jack
            Nov 19 at 15:36
















          Thanks alot! You definitely guided me in the right direction. I looking in the compiled folder provided in chrome source and noticed my code was in fact there. What confuses me is why Javascript works one when locally and another way when in production. But I guess since I know that my code is there i will have to do some serious debugging. Thanks again.
          – Jumping Jack
          Nov 19 at 15:36




          Thanks alot! You definitely guided me in the right direction. I looking in the compiled folder provided in chrome source and noticed my code was in fact there. What confuses me is why Javascript works one when locally and another way when in production. But I guess since I know that my code is there i will have to do some serious debugging. Thanks again.
          – Jumping Jack
          Nov 19 at 15:36


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53366823%2fjavascript-assets-not-loading-to-deployed-heroku-appproduction-but-works-fine%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          Origin of the phrase “under your belt”?