Skip to content
croaky edited this page Sep 13, 2010 · 14 revisions

Modules

Clearance is a Rails engine but it also asks the developer to include two modules. This is meant for override-ability.

Application controller example:

class ApplicationController < ActionController::Base
  include Clearance::Authentication
end

User model example:

class User < ActiveRecord::Base
  include Clearance::User
end

The migration

The generator will also create a migration to add a “users” table and run it. If the table already exists in the database, the migration will just add fields and indexes that are missing and required by Clearance. If the migration fails, the generator will revert all changes back.

Routes

Clearance will add these routes:

Users:

get 'users/new'
post 'users'

Confirmations:

get 'users/:user_id/confirmation/new'
post 'users/:user_id/confirmation'

Session:

get 'session/new'
post 'session'
delete 'session'

Passwords:

get 'users/:user_id/password/new'
post 'users/:user_id/password'
get 'users/:user_id/password/edit'
put 'users/:user_id/password'

The flash

You will need to display the success, failure, and notice flash messages in your layout. We recommend creating an app/layouts/_flashes.html.erb partial similar to the _flashes partial in Suspenders:

<div id="flash">
  <% flash.each do |key, value| -%>
    <div id="flash_<%= key -%>"><%= html_escape(value) %></div>
  <% end -%>
</div>

which is then rendered inside the body tag of your application layout:

<%= render :partial => ‘layouts/flashes’ -%>

Cucumber features

The Cucumber features use Factory Girl 1.2.1.

The generator will create a user factory in test/factories/clearance.rb.