Compiled assets are not found in production mode run locally

83 views
Skip to first unread message

Javix

unread,
Feb 18, 2014, 10:59:57 AM2/18/14
to rubyonra...@googlegroups.com
I have a strange behaviour with compiled assets when running a simple draft app locally:

RAILS_ENV=production rake assets:precompile

The aove command generated some css and js with finger printed values:

i.e. application-43dcf2bdff355d2c3053e2aade23881a.css
application-c67be452a576850d0c11559f908180e3.js

etc.

Run in production:

rails s -e production

There are no CSS fiound !

When observing the html source:

<link href="/assets/application-43dcf2bdff355d2c3053e2aade23881a.css" media="screen" rel="stylesheet">

There are the following errors in the console as well:

F, [2014-02-18T16:56:36.417436 #4036] FATAL -- :
ActionController::RoutingError (No route matches [GET] "/assets/application-43dcf2bdff355d2c3053e2aade23881a.css"):
  actionpack (4.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (4.0.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.0.2) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.0.2) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `block in tagged'
  activesupport (4.0.2) lib/active_support/tagged_logging.rb:25:in `tagged'
  activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `tagged'
  railties (4.0.2) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.0.2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
  rack (1.5.2) lib/rack/runtime.rb:17:in `call'
  activesupport (4.0.2) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
  rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
  railties (4.0.2) lib/rails/engine.rb:511:in `call'
  railties (4.0.2) lib/rails/application.rb:97:in `call'
...

Any idea ? What is wrong here ? Why Rails 4 didn't see my assets ? It is just a simpe app with one generated scaffold for posts, nothing special, no additional configurations added . really weird.


Ganesh Ranganathan

unread,
Feb 18, 2014, 11:08:47 AM2/18/14
to rubyonra...@googlegroups.com

On Tue, Feb 18, 2014 at 9:29 PM, Javix <s.ca...@gmail.com> wrote:
Run in production:

rails s -e production

There are no CSS fiound !

This is strange. This issue can occur for individual css and js files but application.css and application.js should be added by default. 

For other files you have to add config.assets.precompile += %w(filename.css).

Javix

unread,
Feb 18, 2014, 11:22:23 AM2/18/14
to rubyonra...@googlegroups.com
I found the way to make it work:

add/modify the following line in environments/production.rb:

config.serve_static_assets = true
config.assets.compile = true

Then run again

$ RAILS_ENV rake assets:precompile 
$ rails s -e production

And it works. 

Any idea ?

Frederick Cheung

unread,
Feb 18, 2014, 1:32:01 PM2/18/14
to rubyonra...@googlegroups.com
On Tuesday, February 18, 2014 4:22:23 PM UTC, Javix wrote:
> On Tuesday, 18 February 2014 17:08:47 UTC+1, Ganesh Ranganathan wrote:
>


>
> For other files you have to add config.assets.precompile += %w(filename.css).
>
>
> I found the way to make it work:
>
>
> add/modify the following line in environments/production.rb:
>
>
> config.serve_static_assets = true
> config.assets.compile = true
>
>

The default is for .serve_static_assets to be false, since normally in production one lets apache, nginx or a CDN handle static assets

Fred
Reply all
Reply to author
Forward
0 new messages