Skip to content

Instantly share code, notes, and snippets.

@telagraphic
Created December 5, 2011 18:16
Show Gist options
  • Save telagraphic/1434640 to your computer and use it in GitHub Desktop.
Save telagraphic/1434640 to your computer and use it in GitHub Desktop.
Declarative Authorization Problem!
authorization do
role :admin do
has_permission_on [:project, :ticket, :comment, :user], :to => [:index, :show, :new, :create, :edit, :update, :destroy]
end
role :moderator do
has_permission_on :project, :to => []
has_permission_on :project, :to => []
has_permission_on :ticket, :to => [:destroy]
end
role :guest do
has_permission_on :project, :to => [:index, :show]
has_permission_on :ticket, :to => [:index, :show, :create]
has_permission_on :comment, :to => [:new, :create]
end
end
create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at"
t.datetime "updated_at"
t.string "role"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment