I have a couple of sites that are set up in the same way (rails 3.1.3)
as far as I can tell. One of them serves up the assets (js and css)
fine in production the other doesn't.

Both sites have this in their application.html.erb

<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>

Both sites work fine in development but when they run in production
the working site looks like this...

<link href="/assets/application-c4ecd302f7655f2bf6c424146c290463.css"
media="screen" rel="stylesheet" type="text/css" />
<script src="/assets/application-91e6e03ee56f438681c75dcf42c80529.js"
type="text/javascript"></script>

and the broken site looks like this...

<link href="/stylesheets/application.css" media="screen"
rel="stylesheet" type="text/css" />
<script src="/javascripts/application.js" type="text/javascript"></script>

Now I can just insert the correct lines into the application.html.erb
file and things work fine but I would like to know how this should
really be handled.

Does anyone know which configuration option I have overlooked to make this work?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Peter Vandenabeele at Feb 20, 2012 at 11:07 am

    On Mon, Feb 20, 2012 at 11:31 AM, Peter Hickman wrote:

    I have a couple of sites that are set up in the same way (rails 3.1.3)
    as far as I can tell. One of them serves up the assets (js and css)
    fine in production the other doesn't.

    Both sites have this in their application.html.erb

    <%= stylesheet_link_tag "application" %>
    <%= javascript_include_tag "application" %>

    Both sites work fine in development but when they run in production
    the working site looks like this...

    <link href="/assets/application-c4ecd302f7655f2bf6c424146c290463.css"
    media="screen" rel="stylesheet" type="text/css" />
    <script src="/assets/application-91e6e03ee56f438681c75dcf42c80529.js"
    type="text/javascript"></script>

    and the broken site looks like this...

    <link href="/stylesheets/application.css" media="screen"
    rel="stylesheet" type="text/css" />
    <script src="/javascripts/application.js" type="text/javascript"></script>
    What is the exact error message you get in the log file ?

    Now I can just insert the correct lines into the application.html.erb
    file and things work fine but I would like to know how this should
    really be handled.

    Does anyone know which configuration option I have overlooked to make this
    work?
    Well, I could kind of reproduce this issue by abusing the
    config/environments/production.rb with this diff:

    NOT ADVISED for real usage, just for testing ...
    (really don't do this, it will poisen caches for the
    lifetime that is set for the assets)

    @@ -15,10 +15,10 @@ ...::Application.configure do
    config.assets.compress = true

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

    # Generate digests for assets URLs
    - config.assets.digest = true
    + config.assets.digest = false # true

    I presume the config.assets.digest would be the critical
    difference here as setting it to false turns off the addition
    of the digests to the pre-compiled assets.

    Did you diff the config/environments/production.rb on your
    2 systems?

    Did you diff the public/assets/manifest.yml on the 2 systems?

    HTH,

    Peter


    --
    *** Available for a new project ***

    Peter Vandenabeele
    http://twitter.com/peter_v
    http://rails.vandenabeele.com
    http://coderwall.com/peter_v

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Peter Hickman at Feb 20, 2012 at 12:43 pm
    There is no actual error message, just a 404 on the
    /stylesheets/application.css and /javascripts/application.js files and
    no styling or javascript

    I will look at the parameters that you suggest and see if I can make
    sense of them

    Thanks

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Peter Vandenabeele at Feb 20, 2012 at 12:56 pm

    On Mon, Feb 20, 2012 at 1:42 PM, Peter Hickman wrote:

    There is no actual error message, just a 404 on the
    /stylesheets/application.css and /javascripts/application.js files and
    no styling or javascript
    Ok that makes sense.

    Did you run the

    RAILS_ENV=production bundle exec rake assets:precompile

    task recently? Maybe not? It seems like:

    * the precompile task was run with digest ON
    (because the assets with digest are in /public/assets/...)
    * the current production.rb would use it with digest OFF
    (because current rendering of links is without digests)

    In general, you want to use the digested versions.

    Peter


    --
    *** Available for a new project ***

    Peter Vandenabeele
    http://twitter.com/peter_v
    http://rails.vandenabeele.com
    http://coderwall.com/peter_v

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedFeb 20, '12 at 10:32a
activeFeb 20, '12 at 12:56p
posts4
users2
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase