h1. Clearance
Admin feature for Clearance authentication
"We have clearance, Clarence.":http://www.youtube.com/v/mNRXJEE3Nz8
h2. Features
h2. Gem installation (Rails 2.1+)
Specify the gem dependency in your config/environment.rb file:
Rails::Initializer.run do |config|
# ...
config.gem 'dancroak-clearance-admin', :lib => 'clearance-admin', :source => "http://gems.github.com"
end
Then:
rake gems:install
rake gems:unpack
h2. Tests
The tests use "Shoulda":http://thoughtbot.com/projects/shoulda and "Factory Girl":http://thoughtbot.com/projects/factory_girl. Update your User Factory:
Factory.define :user do |user|
user.email { Factory.next :email }
user.password 'sekrit'
user.password_confirmation 'sekrit'
user.admin false
end
In test/unit/user_test.rb:
class UserTest < Test::Unit::TestCase
include Clearance::UserTest
include Clearance::Admin::UserTest
end
h2. Schema
Write a migration:
add_column :users, :admin, :boolean
h2. User Model
In app/models/user.rb:
class User < ActiveRecord::Base
include Clearance::Model
include Clearance::Admin::Model
end
h2. Controllers
In app/controllers/admin/users_controller.rb:
class Admin::UsersController < ActionController::Base
include Clearance::Admin::UsersController
end
h2. Routes
map.namespace :admin do |admin|
admin.resources :users
end
h2. Views
In app/views/admin/users/new.html.erb
<% form_for :session, :url => session_path do |f| %>
<%= f.label :email %>
<%= f.text_field :email %>
<%= f.label :password %>
<%= f.password_field :password %>
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
<%= f.submit 'Login', :disable_with => 'Please wait...' %>
<% end %>
h2. Authors