ZURB Menu

Foundation

Rails

We use Rails to develop our apps and Foundation makes things so much quicker. Start using Foundation in your Rails projects by following these instructions.


Adding Foundation to the Asset Pipeline

First you'll want to add the following gems to the assets group in your Gemfile like so:

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
  # Add Foundation Here
  gem 'compass-rails' # you need this or you get an err
  gem 'zurb-foundation', '~> 4.0.0'
end

Then run bundle install to finish installing Foundation.

NOTE: Make sure that your restart your server after running bundle install. Otherwise the asset pipeline may not recognize the new Foundation files.

Rails 4.0

Rails 4.0 removed the assets group from Gemfile. So make sure to move the zurb-foundation gem out of the assets group, when you're updating your rails app.

Easy Install

Simply run rails g foundation:install to configure your application to use Foundation. That's it!

Manual Installation

Add Foundation to your CSS

Append the following line to your app/assets/stylesheets/application.css file:

/*= require foundation */

If you're planning on using Sass then you'll want to rename application.css to application.scss. That file should then look like:

@import "foundation_and_overrides";
/* Add imports of custom sass/scss files here */
Add Foundation to your JS

Append the following lines to your app/assets/javascripts/application.js file:

//= require foundation
$(document).foundation();
Add Modernizr

Make sure that Modernizr is included in the <head> of your page:

javascript_include_tag "vendor/custom.modernizr"
Set Viewport Width

Add the following line to the <head> of your page layout:

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

This is a modal.

Reveal makes these very easy to summon and dismiss. The close button is simply an anchor with a unicode character icon and a class of close-reveal-modal. Clicking anywhere outside the modal will also dismiss it.

Finally, if your modal summons another Reveal modal, the plugin will handle that for you gracefully.

Second Modal...

×

This is a second modal.

See? It just slides into place after the other first modal. Very handy when you need subsequent dialogs, or when a modal option impacts or requires another decision.

×

This modal has video

×