1

My app works dandy in development but yesterday I tried to move it to my production server and after some work with permissions and paths I though I got it to work. But it seems like I'm unable to load the JS assets while images and css works fine. At first I thought it was the bootstrap js file that made my life misserable but removing it just gives me an error at the next JS asset.

https://dl.dropboxusercontent.com/u/32242733/jsfail.png

Production.rb

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

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

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

  # Disable Rails's static asset server (Apache or nginx will already do this)
  config.serve_static_assets = false

  # Compress JavaScripts and CSS
  config.assets.compress = true

  # Don't fallback to assets pipeline if a precompiled asset is missed
  config.assets.compile = true

  # Generate digests for assets URLs
  config.assets.digest = true

  # Defaults to nil and saved in location specified by config.assets.prefix
  # config.assets.manifest = YOUR_PATH

  # 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

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

  # See everything in the log (default is :info)
  # config.log_level = :debug

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

  # Use a different logger for distributed setups
  # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)

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

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

  # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
  # config.assets.precompile += %w( search.js )

  # Disable delivery errors, bad email addresses will be ignored
  # config.action_mailer.raise_delivery_errors = false

  # Enable threaded mode
  # config.threadsafe!

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

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

  config.action_mailer.default_url_options = { :host => 'example.com' }
  # ActionMailer Config
  # Setup for production - deliveries, no errors raised
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = false
  config.action_mailer.default :charset => "utf-8"

  config.action_mailer.smtp_settings = {
    address: "smtp.gmail.com",
    port: 587,
    domain: "example.com",
    authentication: "plain",
    enable_starttls_auto: true,
    user_name: ENV["GMAIL_USERNAME"],
    password: ENV["GMAIL_PASSWORD"]
  }



  # Log the query plan for queries taking more than this (works
  # with SQLite, MySQL, and PostgreSQL)
  # config.active_record.auto_explain_threshold_in_seconds = 0.5

Assets

root@flypatterns:/var/www/flypatterns/current# ls public/assets/
application-35684ef44e5902293fd317c512600f66.css       glyphicons-halflings.png
application-35684ef44e5902293fd317c512600f66.css.gz    glyphicons-halflings-white-6cccd17a7aed91dbc0157d343c68c0d9.png
application-66ba1e6c258ba515e18111b4b93c8c57.js        glyphicons-halflings-white.png
application-66ba1e6c258ba515e18111b4b93c8c57.js.gz     images
application.css                        jquery.min-6c267bfd2b3f36e6edccb2e584934c1c.map
application.css.gz                     jquery.min.map
application.js                         manifest.yml
application.js.gz                      patterns
gallery_images                         users
glyphicons-halflings-2851b489e8c39f8fad44fc10efb99c3e.png
4
  • By looking at the screenshot it looks like you are able to load the js files but the browser was unable to parse it. Meaning there were some syntax errors in your application.js Commented Apr 19, 2013 at 6:56
  • Wouldn't syntax error show in development? Commented Apr 19, 2013 at 7:25
  • Looks like something has gone wrong in asset pre-compilation or gzipping why dont you delete the assets and do assets pre-compilation again Commented Apr 19, 2013 at 7:32
  • do you use any front-end framework like twitter bootstrap in your app? Commented Apr 19, 2013 at 8:05

4 Answers 4

4

i follow this step for Heroku hello do follwing changes before deploy following file

------enviorment.rb-----

::ActiveSupport::Deprecation.silenced = true

------Production.rb-------

config.assets.compile = ['*.js', '*.css']

config.active_support.deprecation = :silence

-------application.rb-------

config.assets.enabled = true
config.assets.initialize_on_precompile = false
Sign up to request clarification or add additional context in comments.

1 Comment

Both application..rb file changes, and the first Production.rb file change, worked for me to get assets working for a Rails 5 app when running RAILS_ENV=production on my OSX dev localhost.
0

try changing

  config.serve_static_assets = false

to

  config.serve_static_assets = true

Comments

0

I encountered a problem with my app while pushing it to heroku. I had used twitter-bootstrap, there was some errors while precompiling assets. So i switched to manual compiling rather than automatic precompiling. For that i did the following:

I had set initialize_on_precompile to false in config/application.rb as follows:

config.assets.initialize_on_precompile = false

and then i did manually by running:

bundle exec rake assets:precompile RAILS_ENV=production

Finally it worked...

This maynot be the solution you looking for unless you use any predefined front-end frameworks.

Comments

0

check your application.js file i had added some code to do a java script code that added to some funk weird file. the problem was i was missing an "/" for some code that must have been commented out :-( stupid me it took forever

bundle exec rake assets:precompile RAILS_ENV=production

showed me what file and line to look at and i opened that file in sublime. I hope this helps took me5 days to find this damn error smh

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.