1
votes

Trying to run Sprockets 2 in a Rails 2.3 app...

After installing the gem and implementing this in config.ru according to this guide from Pivotal

require 'config/environment' if !defined?(Rails) || !Rails.initialized?
require 'sprockets'

unless Rails.env.production?
map '/assets' do
  sprockets = Sprockets::Environment.new
  sprockets.append_path 'app/assets/images'
  sprockets.append_path 'app/assets/javascripts'
  sprockets.append_path 'app/assets/stylesheets'

  Sprockets::Helpers.configure do |config|
    config.environment = sprockets
    config.prefix      = "/assets"
    config.digest      = false
  end

  run sprockets
  end
end

map '/' do
  use Rails::Rack::LogTailer unless Rails.env.test?
  use Rails::Rack::Debugger unless Rails.env.test?
  use Rails::Rack::Static
  run ActionController::Dispatcher.new
end

Then I created app/assets and moved the javascripts, images, and stylesheets directories out of public and into app/assets. Inside of app/assets/javascripts/application.js I have:

//= require_tree .

Inside of app/assets/stylesheets/application.css I have:

/* ...
*= require_self
*= require_tree .
*/

And of course in layout I have:

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

Something in my configuration is missing, none of my assets will show up. Any tips?

1

1 Answers