Michael
Michael

Reputation: 421

Trouble customizing Zurb Foundation with Rails

I am definitely a novice when it comes to SCSS. I need some help.

I am using the Zurb Foundation gem with my Rails 4.2.4 project. I am trying to make some global customizations such as changing the body-bg color. I've gone into the foundation_and_overrides.scss in my assets/stylesheets folder and uncommented

$body-bg: $white;

looking to change it to $steel or some such. When I reload the page, I get

app/views/layouts/application.html.erb where line #7 raised:

Undefined variable: "$white".

application.html.erb starts out:

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><%= content_for?(:title) ? yield(:title) : "foodian" %></title>
    <meta name="description" content="<%= content_for?(:description) ?     yield(:description) : "Foodian" %>">
    <%= stylesheet_link_tag    "application" %>
    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
    <%# Modernizr is required for Zurb Foundation %>
    <%= javascript_include_tag 'vendor/modernizr' %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
    <%= csrf_meta_tags %>

I'm sure there is something simple I am overlooking. But I can't find any "for dummies" examples of what to do. Please help.

application.css.scss

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any styles
 * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
 * file per style scope.
 *
 *= require_tree .
 *= require_self
 */
/*= require foundation */
@import "foundation_and_overrides";

Upvotes: 1

Views: 106

Answers (1)

taglia
taglia

Reputation: 1847

The way I had this working is to add the following line to app/assets/stylesheets/application.scss, and to add this line:

@import "foundation_and_overrides";

You can also remove any *= require foundation from the same file, as foundation_and_overrides already imports the required files.

I am not sure it is the best way, but it works with Foundation 5 (I have not tried Foundation 6 yet).

Upvotes: 2

Related Questions