Added Admin functionality to Clearance. Based on the work of Jerry: http://github.com/jerry/clearance_admins/
The Clearance engine
Add the plugin:
./script/plugin install git://github.com/srdperu/clearance-admin.git
Run the generate file to create migrations and add the include statements to your Controller and Model files:
Run your new migration files:
You are done!
How does it works?
It will add a new admin column to the User table and new module functionality for filtering users, adding barriers for non-users and non-admins.
If you don’t use the generator, be sure to add
class ApplicationController < ActionController::Base include Clearance::Admin
class User < ActiveRecord::Base include Clearance::Admin::User
You can then restrict access to your controllers like:
class ProjectsController < ApplicationController before_filter :admin_only end
Or even restrict access to non-admin or non-logged users like:
class ProjectsController < ApplicationController before_filter :user_only end
(The MIT License)
Copyright © 2009 FIX
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
‘Software’), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.