Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Using *.css.erb for CSS files with assets inside them?


  • Please log in to reply
2 replies to this topic

#1 Stuart Hannig

Stuart Hannig

    Signalman

  • Members
  • 15 posts

Posted 07 September 2013 - 01:44 AM

This isn';t something mentioned in a tutorial I ran across yet, but upon developing my first app I ran into the problem of having a background image in my CSS, so I wanted to know what the usual course of action is for most developers?

 

My current file is:

custom.css.sass

 

Now do I just rename the file to include the .erb at the end, so I can call the asset pipeline path on the image as so?

.icon{
    background:url(<%= asset_path ("sprites.png") %>) no-repeat -36px -373px;
}

With the file now being named: custom.css.sass.erb?

 

What do you do?


  • james likes this

#2 Rowel

Rowel

    Controller

  • Members
  • 109 posts

Posted 07 September 2013 - 02:42 AM

This is what I use. Try this

custom.css.scss   <---- note extension

background-image: url( image_path('homeimage.jpg'));   <---- image_path  

  • james likes this

#3 Stuart Hannig

Stuart Hannig

    Signalman

  • Members
  • 15 posts

Posted 07 September 2013 - 03:01 AM

Ahhh, okay. Apparently the sass-rails gem allows for some Rails functions to be used in SCSS files. Good to know!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users