GET file.hamljs.js?body=1 404 (Not Found) #7

Open
jejacks0n opened this Issue May 21, 2012 · 8 comments

4 participants

@jejacks0n

Rails 3.2.2
gem 'ruby-haml-js', git: 'https://github.com/dnagir/ruby-haml-js.git'

When you require the templates (or views), the request turns into file.hamljs.js -- while sprockets will actually serve it as file.js.

For instance:

= require file

results in file.hamljs.js

This seems to be a problem with how Sprockets.register_engine '.hamljs' is working, so I'll be doing some digging on where the bug is inside sprockets. Have you seen this before?

@dnagir
Owner

Not sure exactly what you mean.

The spec shows that file named sample.jst.hamljs is happy to be served as sample.js.

Have you tried naming file.jst.hamljs instead of file.hamljs as desribed in the The usage?

But I haven't used it for a while and there could be some changes in Sprockets.

@jejacks0n

Thanks, and yeah, the spec is exactly correct. I have the file named file.jst.hamljs, and it is in fact available at file.js, so your spec is correct.

However, using the sprockets require statement at the top of a file:

//= require file

(in development mode) references file.hamljs.js -- and not file.js like your spec is asserting.

Make more sense? It's clearly an issue in sprockets, but since it effects this gem I figured I'd open it -- since you may have more background than myself.

@dnagir
Owner

Ok. Yes, I see the issue.

I think there's a missing spec that ensures that the correct path is generated (opposite to serving).

Unfortunately I don't have time to dig into that. But will gladly accept a fix for this.

@jejacks0n
@dnagir
Owner

Yes, with additional spec looking like:

it "generate asset path" do
  asset_path_for('sample').should == "/assets/sample.js?body=1"
end
@nickl-

This does not appear to be an issue anymore and even works as expected with rails 4 asset pipeline.

@SeanRoberts

I am still having this issue with Rails 4

@SeanRoberts

Scratch that, changing my Gemfile to reference the version on Git and deleting my tmp/cache folder fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment