You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now that we have changed the Gemfile according to (newest) Heroku needs everyone MUST run
bundle install --without production
You have to run it only once as noted in the README.md (I have updated this file accordingly).
Asset Pipeline in "LOCAL production mode"
During the presentation we (I) failed to show how you run Rails in production mode with Asset Pipeline running.
Well...it was due to a childish error caused by the pressure to finish the presentation early :-)
I will try to explain it here
We did not have any web server (Apache/nginx) to serve our static assets.
Rails production environment was set NOT to serve static assets
So there was no one serving the assets.
Due to this problem we could not see any CSS file.
Heroku case
Nevertheless our Heroku deployment worked as a charm.
Why?
Because the "serve static assets" configuration is done automatically once you include rails_12factor gem so we don't have to do anything.
OK I want to run it locally
To enable this option you can simply open config/environments/production.rb in line 23 and change it to the following
config.serve_static_assets = true
BUT there is a better way:
We can read this option from an ENV variable (or turn it to false by default)
We can use a gem called figaro to set the environment variables from a file called application.yml (ignored by git) instead of the command line
We can make a sample file called application.example.yml (tracked by git) to hold sample key-value pairs so we don't have to remember what to put inside this configuration
AND it gets better!
Make a rake task that automatically generates a ready to use application.yml for setting the production environment in DEVELOPMENT machine.
So we can call from the command line
rake dev:prepare:production_local
and have all the necessary configuration ready.
Then we can run Rails in production mode locally having the (Ruby) application server set to serve the static assets (CSS, JS, Images)
Hey guys and girls!
I've just merged the Pull Requests that have all the steps done in the last presentation plus a couple of things :
Problems running
bundle exec
or./bin/rails s
Now that we have changed the Gemfile according to (newest) Heroku needs everyone MUST run
You have to run it only once as noted in the
README.md
(I have updated this file accordingly).Asset Pipeline in "LOCAL production mode"
During the presentation we (I) failed to show how you run Rails in production mode with Asset Pipeline running.
Well...it was due to a childish error caused by the pressure to finish the presentation early :-)
I will try to explain it here
production
environment was set NOT to serve static assetsSo there was no one serving the assets.
Due to this problem we could not see any CSS file.
Heroku case
Nevertheless our Heroku deployment worked as a charm.
Why?
Because the "serve static assets" configuration is done automatically once you include
rails_12factor
gem so we don't have to do anything.OK I want to run it locally
To enable this option you can simply open
config/environments/production.rb
in line 23 and change it to the followingBUT there is a better way:
figaro
to set the environment variables from a file calledapplication.yml
(ignored by git) instead of the command lineapplication.example.yml
(tracked by git) to hold sample key-value pairs so we don't have to remember what to put inside this configurationAND it gets better!
Make a
rake
task that automatically generates a ready to useapplication.yml
for setting theproduction environment
inDEVELOPMENT machine
.So we can call from the command line
and have all the necessary configuration ready.
Then we can run Rails in production mode locally having the (Ruby) application server set to serve the static assets (CSS, JS, Images)
All the above changes are merged in the PR #32
The text was updated successfully, but these errors were encountered: