Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compass overwrites image_url from sass-rails #500

Closed
stevenyxu opened this issue Jul 31, 2011 · 18 comments
Closed

compass overwrites image_url from sass-rails #500

stevenyxu opened this issue Jul 31, 2011 · 18 comments

Comments

@stevenyxu
Copy link

I wanted to add compass to an existing Rails 3.1.0.rc5 app that I have. I added the gem to the Gemfile, and used Ken Collins' fix to get the asset pipeline to recognize the compass framework stylesheets.

However, in the process of doing so, compass seemed to overwrite the recently-introduced image_url helper from sass-rails, which would break the links to precompiled assets in the production environment (it would link to /assets/my.png?12345 rather than /assets/my-12345.png)

@scottdavis
Copy link
Member

this is a known issue and chris is "working on it"

@spohlenz
Copy link

spohlenz commented Aug 5, 2011

If it's of any help, requiring compass before sass-rails seems to work around the issue for me.

@stevenyxu
Copy link
Author

Indeed; sass-rails just overwrites the method. Thanks for the suggestion in
any case. Here's hoping it saves time for others folks who stumble on this
issue. I'm only sorry I didn't post the solution myself. I don't want to
become "oh I fixed it. nvm"-guy.

On Fri, Aug 5, 2011 at 12:56 AM, spohlenz <
reply@reply.github.com>wrote:

If it's of any help, requiring compass before sass-rails seems to work
around the issue for me.

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

@scottdavis
Copy link
Member

the issue is that compass and sass-rails image_url helpers take different arguments. compass needs to be able to detect if sass-rails is loaded and alias the functions

@huerlisi
Copy link

huerlisi commented Aug 7, 2011

@spohlenz and how do you achieve compass being required before sass-rails? Switching lines in Gemfile didn't help, adding an initializer requiring them didn't work out, either.

@spohlenz
Copy link

spohlenz commented Aug 7, 2011

@huerlisi an initializer is probably to late in the boot process. Try putting the requires directly in config/application.rb.

@huerlisi
Copy link

huerlisi commented Aug 8, 2011

@spohlenz thanks, works now!

@johnnym
Copy link

johnnym commented Aug 8, 2011

@huerlisi, can you explain what you did exactly? I added require 'compass' and require 'sass-rails' to config/application.rb, but it seems that image-url still isn't being overridden by sass-rails.

@huerlisi
Copy link

huerlisi commented Aug 8, 2011

@huerlisi
Copy link

huerlisi commented Aug 8, 2011

@johnnym, just realizing that I had to play a bit with rake assets:clean and rake tmp:clear to get the stylesheet actually rebuilt.

@johnnym
Copy link

johnnym commented Aug 8, 2011

Thanks! The cache was the problem. I would have expected it to have been rebuilt automatically since I changed all the asset-url's I was using to image-url, but clearing it worked.

@scottdavis
Copy link
Member

Just to warn you all the above solution is not the correct one it may make it work but the compass and sass-rails helpers take different arguments so down the line once this is fixed you will have to refactor.

https://github.com/rails/sass-rails/blob/master/lib/sass/rails/helpers.rb#L13
https://github.com/chriseppstein/compass/blob/master/lib/compass/sass_extensions/functions/urls.rb#L51

@dfischer
Copy link

Any updates on this issue?

@scottdavis
Copy link
Member

Chris wants to do a alpha this week I think

Sent from my iPhone

On Aug 25, 2011, at 12:23 PM, dfischerreply@reply.github.com wrote:

Any updates on this issue? Seems pretty major...

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

@alanhogan
Copy link

See also: #519. Probably the same issue, but none of the fixes in this thread have worked for me.

@stevenyxu
Copy link
Author

For the folks who need a fix "yesterday", I can still manage to get around the issue (in what I hope is a forwards-compatible way) by using an ERB stylesheet instead. So, I still have the old included stylesheet:

.fancy-list {
  li {
    &.linked {
      background-image: image-url('right-arrow.png');
    }
  }
}

But then, I've just added a line to "application.css.scss.erb" (rename if necessary):

.fancy-list li.linked {
  background-image: url(<%= image_path("right-arrow.png") %>);
}

In some future point when this gets fixed, I can remove the line from application.css or even just leave it as is and it should work.

@aaronchi
Copy link
Contributor

works more simply with

.fancy-list li.linked {
  background-image: url(image_path("right-arrow.png"));
}

only the image_url function seems to be affected

@scottdavis
Copy link
Member

this should be fixed in the current alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants