The pipeline does not work: css and js files do not compile on the fly

I started creating new Rails 3.2.5 projects, and the asset pipeline no longer works. CSS and Javascript files no longer compile.

This is the result of the logs when trying to generate an asset:

    Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2012-06-16 23:59:11 -0700
Served asset /application.css - 200 OK (0ms)
[2012-06-16 23:59:11] ERROR NoMethodError: undefined method `each' for nil:NilClass
    /Users/greg/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rack-1.3.6/lib/rack/handler/webrick.rb:71:in `service'
    /Users/greg/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
    /Users/greg/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
    /Users/greg/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:

Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2012-06-16 23:59:11 -0700
Served asset /application.js - 200 OK (0ms)
[2012-06-16 23:59:11] ERROR NoMethodError: undefined method `each' for nil:NilClass
    /Users/greg/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/rack-1.3.6/lib/rack/handler/webrick.rb:71:in `service'
    /Users/greg/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
    /Users/greg/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
    /Users/greg/.rbenv/versions/1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
183:in `block in start_thread'

Update

<!DOCTYPE html>
<html>
<head>
  <title>Shorai</title>
  <%= csrf_meta_tags %>
</head>
<body id=<%= params[:controller].sub('_controller', '') %>>

  <% if current_user %>
    <%= current_user.name %>
    <%= link_to "Log out", signout_path %>
  <% else %>
    <%= link_to "Sign in", "/auth/37signals" %>
  <% end %>

  <%= yield %>

  <%= stylesheet_link_tag    "application", :media => "all" %>
  <%= javascript_include_tag "application" %>
</body>
</html>

Update2:

application.scss

 *
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the top of the
 * compiled file, but it generally better to create a new file per style scope.
 *
 *= require_self
 *= require_tree .
 */

Update3: http://f.imgtmp.com/Onpqv.png

I do not know what causes this, who has an idea? Greg

+5
source share
4 answers

I got this error when I turned on caching (in development mode) with the memcached repository, but the memcached process was not started (Rails 3.2.8, Win7).

So the solution was to just start memcached and restart the Rails server.

+7
source

memcache (config.cache_store = :dalli_store). , Rack:: Cache (config.action_dispatch.rack_cache = nil)

config.action_dispatch.rack_cache = {
  :metastore    => Dalli::Client.new,
  :entitystore  => 'file:tmp/cache/rack/body',
  :allow_reload => false
}

. https://github.com/rails/rails/issues/8366.

+3

, dev. , " "

+2

-v 3.2.5.

. , , , - !

, , ...

config/application.rb ... :

config.assets.paths << Rails.root.join("app", "assets", "stylesheets")
config.assets.paths << Rails.root.join("app", "assets", "javascripts")
config.assets.paths << Rails.root.join("vendor", "assets", "stylesheets")
config.assets.paths << Rails.root.join("vendor", "assets", "javascripts")
config.assets.paths << Rails.root.join("lib", "assets", "javascripts")

If you have assets in the engines, they should also be explicitly added. It worked fine in -v 3.1.x. The fact that this workaround fixes the problem seems to indicate an error (of course, others would have already found it) or a configuration change in 3.2.5.

+1
source

All Articles