0

I am attempting to migrate our application to use the Asset Pipeline, so i have been testing my changes locally (using the built in Webrick server). My production.rb looks like this:

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

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

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

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

Note, the config.serve_static_assets = true

This works perfectly, in that i can run

rm -rf tmp
rm -rf public/assets
RAILS_ENV=production bundle exec rake assets:clean
RAILS_ENV=production bundle exec rake assets:precompile 
rails server -p 3500 -e production

On my local machine and everything loads fine. However, now i want to push my changes to our production Apache server i want Apache to serve assets, so i set:

config.serve_static_assets = false

If i now try to load up a production rails server on my local box, the static assets do not load. I am not sure whether this is expected behaviour or not (i mean, i'm telling Rails not to serve me static assets and it isn't - but i want something to serve them to me).

So my question is, how can i have config.serve_static_assets = false in my production.rb while still being able to run local production rails servers? Is what i'm asking even possible or sensible?

Thanks

Note: using Rails 3.2.11

rwb
  • 4,309
  • 8
  • 36
  • 59

1 Answers1

0

Together with the rake assets:precompile you should instruct your webserver to serve the public folder.

Are you using Passenger for deployment?

See http://www.modrails.com/documentation/Users%20guide%20Apache.html and in particular:

Listen *:80
NameVirtualHosts *:80
....

LoadModule passenger_module /somewhere/passenger-x.x.x/ext/apache2/mod_passenger.so

PassengerRuby /usr/bin/ruby
PassengerRoot /somewhere/passenger/x.x.x
PassengerMaxPoolSize 10

<VirtualHost *:80>
    ServerName www.foo.com
    DocumentRoot /webapps/foo/public
    RailsBaseURI /rails
</VirtualHost>

And

<Directory "/webapps/mycook/public">
   Options FollowSymLinks
   AllowOverride None
   Order allow,deny
   Allow from all
</Directory>
baol
  • 4,362
  • 34
  • 44