Wednesday, October 10, 2012

Some Rails 3 layout customization notes from a beginner

While starter tutorial is definitely helpful.  A few nuts and bolts that I've picked up thus far for layout customization aside from the more advanced assets pipeline guide.

  For general application wide style layout, the application.css is available.  However, if you need to reference asset data inside such css.  It may be important to change your style sheet from .css to .css.erb .  Assets pipeline guide indicates rails call where this applies (inside your html.erb file).  For this I'd cite the following applied examples:

@font-face { font-family: Yanone Kaffeesatz; src: src: url(<%= stylesheet_link_tag "YanoneKaffeesatz-Regular.ttf" %>); }

noting here the ruby url call is

<%= stylesheet_link_tag "YanoneKaffeesatz-Regular.ttf" %>

in this example.

Similarly,


header {
  background: #323534 url(<%= asset_path 'back.png' %>) repeat-x;
  height: 153px;
}

using the asset_path at least in the rails call inside your style sheet requires the .css.erb file path extension here for proper Rails execution of this line inside such stylesheet.

-I've used the public/assets folder for containing collections of image data in my site construction which links also to the 'asset_path' pipeline.

-In a given default Rails 3 application, by default the reference to, for instance, the application.css.erb style sheet will be found in the application.html.erb file

<%= stylesheet_link_tag    "application", :media => "all" %>

One would note the stylesheet_link_tag also controlling the link in the case to either .css or .css.erb stylesheets.



No comments:

Post a Comment

Oblivion

 Between the fascination of an upcoming pandemic ridden college football season, Taylor Swift, and Kim Kardashian, wildfires, crazier weathe...