Hello guys,

I tried to get an image-background working within my page, but I was
wrong...

I´m using rails 3.2.3, ruby 1.9.3 p125.

thats a part of my css file (app/assets/stylesheets/custom.css.scss):


body {
padding-top: 70px;
background: url(<%= asset_path 'background.png' %>);
}

and if i try to access the page, rails server sais


ActionView::Template::Error (Invalid CSS after " background:
url(": expected ")", was "<%= asset_path ..."
(in
/home/basti/website/Azubiware_2.0/app/assets/stylesheets/custom.css.scss)):
2: <html>
3: <head>
4: <title>Azubiware 2.0 | <%= @title %></title>
5: <%= stylesheet_link_tag "application", media: "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: <!--[if lt IE 9]>
app/assets/stylesheets/custom.css.scss:9
app/views/layouts/application.html.erb:5:in
`_app_views_layouts_application_html_erb___3677715865169271541_23617180'


Any idea how to get this background foo working?

Very thanksfull for every hint!

Basti

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Kevin Bedell at Apr 11, 2012 at 8:42 pm
    Here an example line from one of our scss files:

    background: image-url("email_icon.png") no-repeat 0px 4px;

    Try that?

    On Wed, Apr 11, 2012 at 3:22 PM, Sebastian H. wrote:
    Hello guys,

    I tried to get an image-background working within my page, but I was
    wrong...

    I´m using rails 3.2.3, ruby 1.9.3 p125.

    thats a part of my css file (app/assets/stylesheets/custom.css.scss):


    body {
    padding-top: 70px;
    background: url(<%= asset_path 'background.png' %>);
    }

    and if i try to access the page, rails server sais


    ActionView::Template::Error (Invalid CSS after "        background:
    url(": expected ")", was "<%= asset_path ..."
    (in
    /home/basti/website/Azubiware_2.0/app/assets/stylesheets/custom.css.scss)):
    2: <html>
    3:   <head>
    4:     <title>Azubiware 2.0 | <%= @title %></title>
    5:     <%= stylesheet_link_tag    "application", media: "all" %>
    6:     <%= javascript_include_tag "application" %>
    7:     <%= csrf_meta_tags %>
    8:     <!--[if lt IE 9]>
    app/assets/stylesheets/custom.css.scss:9
    app/views/layouts/application.html.erb:5:in
    `_app_views_layouts_application_html_erb___3677715865169271541_23617180'


    Any idea how to get this background foo working?

    Very thanksfull for every hint!

    Basti

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Sebastian H. at Apr 11, 2012 at 8:48 pm
    that worked for me :) yeah.. you made my evening! thanks

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Linus Pettersson at Apr 11, 2012 at 8:56 pm
    To run the first code you tried you need to add the .erb extension.
    Otherwise, it's like running ruby code in a css/html file or whatever. It
    doesn't work :)

    The assets pipeline works like this:
    example.css.scss => Interprets scss first and serves the css file.
    example.html.erb => interprets erb first and serves the html file.
    example.css.scss.erb => interprets erb first, then scss and serves the css
    file to the client.
    ... and so on.

    The "image-url()" code that kbedell suggested above works because it's a
    scss helper method for rails.

    Hope that clears things up a bit :)

    Cheers!

    Den onsdagen den 11:e april 2012 kl. 22:48:16 UTC+2 skrev Ruby-Forum.com
    User:
    that worked for me :) yeah.. you made my evening! thanks

    --
    Posted via http://www.ruby-forum.com/.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/HS1x4XBm_8AJ.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedApr 11, '12 at 7:22p
activeApr 11, '12 at 8:56p
posts4
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase