documentcloud / jammit

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

Using a period in template_extension causes a 404 error. (html.mustache) #69

Closed john-griffin closed 13 years ago

john-griffin commented 13 years ago

Hi,

When I use html.mustache as the template_extension, file name and asset reference I get a 404 from the browser:

workspace.html.mustache Failed to load resource: the server responded with a status of 404 (Not Found)

Renaming all of those to just htmlmustache without the period works. I am on Rails 3 and Ruby 1.9.2.

Thanks!

agibralter commented 13 years ago

Hmm on Rails 2.3.9 with Ruby 1.8.7 template_extension: "html.mustache" works fine for me...

john-griffin commented 13 years ago

I have narrowed it down a bit. Looking at the rails log when using a period the parameter extension is just html. Where as losing the period gives the param as htmlmustache.

Started GET "/assets/workspace.htmlerb" for 127.0.0.1 at 2010-09-23 23:08:13 +0100 Processing by Jammit::Controller#package as */* Parameters: {"package"=>"workspace", "extension"=>"htmlmustache"} Completed 200 OK in 15ms (Views: 12.3ms)

Started GET "/assets/workspace.html.erb" for 127.0.0.1 at 2010-09-23 23:10:54 +0100 Processing by Jammit::Controller#package as Parameters: {"package"=>"workspace", "extension"=>"html"} Rendered public/404.html (0.5ms) Completed 404 Not Found in 26ms (Views: 25.0ms)

So it could be something to do with the extension matching.

agibralter commented 13 years ago

Ahh Yeah, I think Rails 3 treats routes differently:

map.jammit "/#{Jammit.package_path}/:package.:extension" ...

vs.

match "/#{Jammit.package_path}/:package.:extension" ...

I think Rails 3 has different precedence... not sure how to fix it though because I haven't delved into 3.0.0 yet.

jashkenas commented 13 years ago

I've merged john-griffin's patch to master. Closing the ticket.