-
Notifications
You must be signed in to change notification settings - Fork 276
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
Doesn't work with Rails Engines #107
Comments
@jeyb Keep us posted with this one. I have no clue how to fix, but am looking to integrate compass into my first Rails App/Engine |
@jpdesigndev The problem was that the asset paths weren't being included from the engine's gems. I've found including the required gem within the main application as well as the engine's gemspec solved it. |
Awesome. Thanks for the help. I'm assuming you were able to import compass related stuff from inside the engines app/assets right? |
Try adding The reason for this is that gems included in the application's Gemfile are usually required automatically. However gem dependencies need to be explicitly required. |
@spohlenz that worked. Thanks. |
Hi, any clue on how to set the sprite load path to also use the engine's own assets directory? |
Hi @dimerman, guys. I was working on a structure of basically 5 folders in the same level, 2 of them are rails app and the other are internal gems used on both apps, and I was trying to use compass-rails to avoid having a duplicated "icons" folder on both apps, moving the folder inside on of the gems. I had a bunch of problems with that and, after struggling for about a day, I've overwritten the require 'compass-rails'
module Compass::SassExtensions::Functions::InlineImage
def inline_image(path, mime_type = nil)
path = path.value
images = Rails.application.assets.paths.select{|pa| pa =~ /image/}
images << Compass.configuration.images_path
images.each do |image|
real_path = File.join(image, path)
if File.exists? real_path
return inline_image_string(data(real_path), compute_mime_type(path, mime_type))
end
end
end
end Hope that can be useful for anyone else and I'd love to know from the maintainers if this can be interesting to have inside the gem itself, I would love to work to reach something like this. |
@miguelgraz Much cleaner variant: module Compass::SassExtensions::Functions::InlineImage
def inline_image(path, mime_type = nil)
path = path.value
pathname = Rails.application.assets.find_asset(path).pathname
raise Compass::Error, "File not found or cannot be read: #{pathname}" unless pathname.exist?
computed_mime_type = compute_mime_type(path, mime_type)
inline_image_string(data(pathname), computed_mime_type)
end
end |
Indeed, thank you for that! |
However what about merging this into the compass-rails gem? |
Btw, @miguelgraz I fixed it in my app using following line in my initializer 'compass' do
Compass.configuration.project_path = root
end |
For others that stumble on this recently, the namespace is |
I have the same or very similar problem. I have a Rails 'gem 'rails', github: "rails/rails", branch: "3-2-stable"' app, which loads an Engine which contains most of the functionality of our app. We've configured the Engine so that it is a bootable Rails app and it loads compass fine. compass (= 0.12.6) However, when we load this engine from another parent app using the same Gemfile as the Engine we get the error. Sass::SyntaxError: File to import not found or unreadable: compass I've tired as many solutions as I have seen on the multiple issues with similar side effects, requiring 'rails-engine' in engine.rb, Setting the project_path within the engine and in an initializer, I've upgraded the above gems as much as I can but nothing. A few puts inside ImportNode#import show that load_paths do not include the compass directories...
- /Users/rl/repos/project/vendor/gems/project/app/assets/stylesheets/frontend_root.sass
- /Users/rl/repos/project/vendor/gems/project/app/assets/stylesheets/root_tree.sass
Not sure where to go from here. Any ideas? |
I was trying to use compass-rails and i am running into issues with inline-images. Previously i was using compass and everything seems to work fine. But now inline-image function is not working. How to get it work with compass-rails. Any suggestions? |
There was a similar problem discussed #88 but this doesn't seem to solve my issue. The solution provided there is for sprite load path.
I have a Rails 3.2.15 app. There is no mention of compass-rails or sass-rails within this application Gemfile. Within
vendor/engines
I have a Rails engine that has the following in the gemspec.The Rails engine is included in the Gemfile of the main application. Therefore the Gemfile.lock includes compass-rails and sass-rails as one would expect. However I believe there is an issue with load paths as
@import compass/css3
fails with:The text was updated successfully, but these errors were encountered: