tenex / rails-assets

The solution to assets management in Rails
https://rails-assets.org
MIT License
1.63k stars 69 forks source link

bootstrap-formhelpers doesn't work: not existing images are replaced with "image-url(".")" #150

Closed jmuheim closed 10 years ago

jmuheim commented 10 years ago

There's an image ../img/eu.png specified in bootstrap-formhelpers-flags.less:

´´´ .bfh-flag-EUR{ background: url(../img/eu.png) no-repeat; }

.bfh-flag-XCD{ background: url(../img/xcd.png) no-repeat; } ´´´

But this image doesn't exist. Rails-assets now compiles it to the following:

.bfh-flag-EUR{
  background: image-url(".") no-repeat;
}

.bfh-flag-XCD{
  background: image-url(".") no-repeat;
}

This causes Rails to raise this error:

error evaluating function `image-url`: couldn't find file '.'
jmuheim commented 10 years ago

I know that this is mainly a problem of bootstrap-formhelpers, but replacing missing images with "." doesn't sound very sensible?

sheerun commented 10 years ago

We could leave url as is if Image doesn't exist (no image- prefix). Could you send a PR?

On Thursday, May 8, 2014, Joshua Muheim notifications@github.com wrote:

I know that this is mainly a problem of bootstrap-formhelpers, but replacing missing images with "." doesn't sound very sensible?

— Reply to this email directly or view it on GitHubhttps://github.com/rails-assets/rails-assets/issues/150#issuecomment-42519665 .

jmuheim commented 10 years ago

Sure. Can you give me a hint where the corresponding code is? I forked rails-assets but don't find it.

sheerun commented 10 years ago

It's here: https://github.com/rails-assets/rails-assets/blob/master/app/models/build/transformer.rb#L153

A test would be welcome too :) You can stub .exist?

jmuheim commented 10 years ago

Haha, my texteditor ignored build directories in global search...

jmuheim commented 10 years ago

Why do you require postgres to be installed for development? I get errors like

An error occurred while installing pg (0.16.0), and Bundler cannot continue.

when bundling.

jmuheim commented 10 years ago

Also, I'm a bit unsure how to correctly address this issue. Should I only check whether the returned path is "."?

sheerun commented 10 years ago

I cannot help you with installing pg without error message. probably SQLite works too, but I didn't test. Better detect if file exists and return nil instead of .

sheerun commented 10 years ago

The bug is fixed. I'll notify about deployment on our twitter account.