documentcloud / jammit

Industrial Strength Asset Packaging for Rails
http://documentcloud.github.com/jammit/
MIT License
1.16k stars 197 forks source link

Jammit Routes not loaded in production mode when a catchall is present #87

Closed shaicoleman closed 13 years ago

shaicoleman commented 13 years ago

Jammit 0.5.4, Rails 3.0.1

When a catchall route is present, the Jammit routes aren't loaded in production mode: match '*path' => 'mycontroller#catchall'

The jammit routes should be loaded earlier to prevent this issue.

jashkenas commented 13 years ago

In Rails 3 -- we're simply using the Rails API for routing. We don't decide when the route gets loaded, Rails 3 does. If you'd like to fix this for your app, I'd suggest adding the route yourself:

match "/#{Jammit.package_path}/:package.:extension",
  :to => 'jammit#package', :as => :jammit, :constraints => {
    # A hack to allow extension to include "."
    :extension => /.+/
  }
larskuhnt commented 13 years ago

You could prepend instead of append the jammit route in lib/jammit/railtie.rb:

app.routes_reloader.paths.insert 0, File.join(File.dirname(__FILE__), "..", "..", "rails", "routes.rb")

then it gets loaded first.

Cheers Lars