dnagir / ruby-haml-js

HAML-JS Tile and Rails 3.1 Template

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

jejacks0n opened this issue · comments

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?

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.

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.

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.

So, I would expect the fix is to remove the jst portion of the filename. I'll try and figure that out tomorrow if I can.

Thanks.

On May 20, 2012, at 9:48 PM, Dmytrii Nagirniak wrote:

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.


Reply to this email directly or view it on GitHub:
#7 (comment)

Yes, with additional spec looking like:

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

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

I am still having this issue with Rails 4

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