How to generate an static web from a Rails project

Posted by Daniel Vela on September 16, 2016

IMPORTANT: This method only works if the output static web files are served from a web server and the files are served from the root directory of the web server

Precompile assets with:

  $ bundle exec rake assets:precompile

Open config/enviroments/production.rb and change the following attribute to true:

  config.serve_static_assets = true

Run the server in production mode

  $ rails s -e production

then execute wget command:

  $ wget -P static -nH -m http://localhost:3000

Parameters:

  • -P prefix directory. the base directory to write web
  • -nH no-host-directories. Don’t create the base direcotry with the site name
  • -m man mirror equivalent to -r -N -l inf –no-remove-listing