How to Create Sprite Images using Compass Rails Gem in Rails 4.2.5
Create a new rails project.
Copy icons to
Create a sprites folder in
compass-rails to Gemfile. Run:
Create your resource.
rails g scaffold article title:string content:text
Add, the following to
@import "compass/utilities/sprites"; @import "icons/*.png"; @include all-icons-sprites;
Read the compass gem home page to learn more about these declarations.
production.rb, enable assets and configure the folder where the generated sprite images should be stored.
config.assets.enabled = true config.compass.generated_images_dir = “app/assets/images/sprites”
You can also add it to
development.rb for testing locally in development environment.
You will see the generated sprite file in
app/assets/images/sprites folder. Add
Sample source code can be downloaded from
In this article, you learned how to use compass-rails gem to generate sprite images for Rails 4.2.5 apps. It reduces the number of files to download from a server and therefore improves the performance.
Software Compatibility Best Practices
I spoke to some of the most talented and experienced software developers. I have created a guide that is filled with valuable insights and actionable ideas to boost developer productivity.
You will gain a better understanding of what's working well for other developers and how they address the software compatibility problems.