Assets not loading in production

Hello,

(Rails 4, Ruby 2)

I am trying to deploy my first rails app in a production environment,
but
cannot get the assets to load. The site is hosted on Webfaction, they
advise to create a “static app” to serve the assets which I have done.
But
I don’t understand how my rails app then knows about the static app.

At the moment, in production inside the head it prints out…

“/stylesheets/application.css”
“/javascripts/application.js”

But I want it to be “/assets/stylesheets/application.css”.

Any help or advise would be most welcome.

On Sat, Oct 12, 2013 at 9:45 AM, Phillip [email protected] wrote:

I am trying to deploy my first rails app in a production environment, but
cannot get the assets to load. The site is hosted on Webfaction, they advise
to create a “static app” to serve the assets which I have done. But I don’t
understand how my rails app then knows about the static app.

I don’t even want to know what they are talking about or implying
because it sounds wrong. By default in production on a Rails 4
application it prefers you to pass asset serving up higher in the
chain because it will be much quicker for nginx/apache to serve the
app than it will be for Rails to serve it especially considering you
have to proxy to rails who then has to send it back and then it gets
served.

This means that when you build a new app you need to make sure you
have a proper root set (or a sub-domain) that can lead to the public
folder and each time you deploy you need to do rake assets:precompile to get your assets to work. If you do not wish
this to be the case then set your production.rb to serve static assets
and go on about your way as you will not need to have nginx/apache
care about it.

At that point your Rails application will know the asset path and you
will have access to public/assets/$(name)-$(hash).$(ext).

Thanks Jordon, that’s giving me a few things to go on. (Off to
investigate…)

you should try this command rake assets:precompile RAILS_ENV=development