Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Basic Rails framework files and assets for layout and authentication
Ruby CSS Other
tag: v1.0.0.beta

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


Contour Dependency Status

Basic Rails framework files and assets for layout and authentication


Contour can be installed from using:

gem install contour

Or update your Gemfile to include:

gem 'contour'

Getting started

Contour depends on a config initializer. The config initializer is used to set various default settings in the layout, and also allows the menu to be created using a ruby hash. To install a template you can run:

rails generate contour:install

Contour uses a template to generate your application layout. You can add the following in your application_controller.rb:

layout "contour/layouts/application"

Contour also provides a custom jquery-ui and BlueTrip CSS Framework. To include these, add the following to your application.css manifest (after “*= require_self” and before “*= require_tree .”):

*= require contour

Contour provides custom JavaScript. In order to make the application layout function properly include the following at the beginning of your application.js (before “//= require_tree .” replacing “//= require jquery” and “//= require jquery_ujs”):

//= require contour

In order to get registration working, you can use the modified Contour Authentications controller which overrides the default devise controller of the same name:

devise_for :users, controllers: { registrations: 'contour/registrations', sessions: 'contour/sessions', passwords: 'contour/passwords' }, path_names: { sign_up: 'register', sign_in: 'login' }

Setting up a new project with quick authentication

Make sure you have Rails 3.2.1

rails -v

rails new blank_rails_project

cd blank_rails_project

Modify Gemfile and add

gem 'contour', '~> 1.0.0'          # Basic Layout and Assets

Run Bundle install

bundle install

Install contour files

rails generate contour:install

Add the authentication model

rails generate model Authentication user_id:integer provider:string uid:string

Migrate your database

bundle exec rake db:create

bundle exec rake db:migrate

Create a sample controller

rails generate controller welcome index --skip-stylesheets

Remove the public/index.html

rm public/index.html

Add the following line to your app/controllers/application_controller.rb

layout "contour/layouts/application"

Edit your app/assets/javascripts/application.js manifest to use Contour JavaScript (Replace jquery and jquery_ujs)

//= require contour

Edit your app/assets/stylesheets/application.css manifest to use Contour CSS (after self, before tree)

*= require contour

Make sure the devise line in config/routes.rb looks as follows

devise_for :users, controllers: { registrations: 'contour/registrations', sessions: 'contour/sessions', passwords: 'contour/passwords' }, path_names: { sign_up: 'register', sign_in: 'login' }

If there is a line that just says 'devise_for :users' or a duplicate, REMOVE IT!

Create a root in your config/routes.rb

root to: 'welcome#index'

Add the following to your app/models/user.rb

attr_accessible :first_name, :last_name

# Model Validation
validates_presence_of     :first_name
validates_presence_of     :last_name

# Model Relationships
has_many :authentications

def apply_omniauth(omniauth)
  unless omniauth['info'].blank? = omniauth['info']['email'] if email.blank?
    self.first_name = omniauth['info']['first_name'] if first_name.blank?
    self.last_name = omniauth['info']['last_name'] if last_name.blank?
  end provider: omniauth['provider'], uid: omniauth['uid'] )

def password_required?
  (authentications.empty? || !password.blank?) && super

Add the following to your app/models/authentication.rb

belongs_to :user

def provider_name
  OmniAuth.config.camelizations[provider.to_s.downcase] || provider.to_s.titleize

Edit config/initializers/devise.rb to use :get for devise sign_out_via

# The default HTTP method used to sign out a resource. Default is :delete.
config.sign_out_via = :get

Start your server and navigate to localhost:3000/users/login

rails s

You can then sign in using your Google Account or by registering for an account at localhost:3000/users/register

Contributing to contour

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet

  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.


Copyright © 2012 Remo Mueller. See LICENSE for further details.

Something went wrong with that request. Please try again.