Skip to content

Commit

Permalink
added an allowed? helper
Browse files Browse the repository at this point in the history
  • Loading branch information
atog committed Jun 5, 2009
1 parent 3a8e2b1 commit e3970d8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Expand Up @@ -44,6 +44,21 @@ The User model
include Roleify::RoleifyableModel
end

The Helper
----------

module ApplicationHelper
include Roleify::RoleifyableHelper
end


The View
--------

<% allowed?(Roleify::Role::ROLE_A) do %>
whatever you want for role_a eyes only
<% end %>

Extra's
=======

Expand Down
11 changes: 11 additions & 0 deletions lib/roleify/roleifyable_helper.rb
@@ -0,0 +1,11 @@
module Roleify
module RoleifyableHelper

def allowed?(*roles, &block)
if roles && (current_user.admin? || roles.include?(current_user.role))
concat capture(&block)
end
end

end
end

0 comments on commit e3970d8

Please sign in to comment.