アークウェブ
システム開発
SandBox
Web制作会社アークウェブのスタッフが、システム開発のTips・ノウハウをまとめているWikiです
アークウェブシステム開発SandBox
アークウェブWebマーケティングSandBox
アークウェブWebデザインSandBox
アークウェブ アクセシビリティWiki
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
- 認証プラグインとしてデファクトスタンダードな「RESTfulAu...
- timcharperさんが作った「[[role_requirement:http://githu...
- 参考: Usage - role_requirement - GitHub http://wiki.git...
** インストール [#e74f99d6]
- 次のコマンドを実行
script/plugin install git://github.com/technoweenie/rest...
script/plugin install git://github.com/timcharper/role_r...
** セットアップ [#mab2b4d4]
- 次のコマンドを実行
./script/generate authenticated user sessions
./script/generate roles Role User
- Userは、authenticatedに指定したモデルクラス名
- Roleは、権限をあらわすモデル名
- 次のファイルが作らる
test/fixtures/users.yml
test/fixtures/roles.yml
app/models/role.rb
lib/role_requirement_system.rb
lib/role_requirement_test_helper.rb
lib/hijacker.rb
db/migrate/20100111002832_create_roles.rb
- テーブルを作る
rake db:migrate
- 次のテーブルができた
-- roles
-- roles_users
** 使い方 [#e34f21f2]
- rolesとusersはhabtmの関係
- rolesには「name」というカラムがあるだけ
- rolesに「admin」「user」などの値を持つレコードをいれて...
- コントローラー内に宣言的に記述
-- このコントローラーのすべてのアクションはadmin権限が必要
require_role "admin"
-- このコントローラーのindexアクション以外はadmin権限が必要
require_role "admin", :for_all_except => :index
-- このコントローラーのindexアクションはadmin権限が必要
require_role "admin", :for => :index
-- このコントローラーのすべてのアクションは「admin」と「e...
require_role "admin"
require_role "executive"
-- このコントローラーのすべてのアクションは「admin」と「e...
require_role "admin"
require_role "executive", :except => [:index]
-- このコントローラーのすべてのアクションは「admin」権限...
require_role "admin"
require_role "executive", :only => [:create, :update, :...
-- このコントローラーのすべてのアクションは「admin」権限...
require_role ["admin", "executive"]
-- このコントローラーの「list」アクションと「show」アクシ...
require_role "admin", :except => [:list, :show]
-- このコントローラーの「delete」アクションと「edit」アク...
require_role "admin", :only => [:delete, :edit]
- current_userに指定されたroleが紐づいていれば、要求され...
- 紐づいていなければ AuthenticatedSystemのaccess_denied ...
** 常に「admin」というroleの人はなんでも許可されるように...
- デフォルトでそうなっている
- app/model/user.rbに次のメソッドが追加されるているため
def has_role?(role_in_question)
@_list ||= self.roles.collect(&:name)
# return true if @_list.include?("admin") #This is the ...
(@_list.include?(role_in_question.to_s) )
end
#blikifooter(志田)
tag: [[Ruby on Rails>tag/Ruby on Rails]]
終了行:
- 認証プラグインとしてデファクトスタンダードな「RESTfulAu...
- timcharperさんが作った「[[role_requirement:http://githu...
- 参考: Usage - role_requirement - GitHub http://wiki.git...
** インストール [#e74f99d6]
- 次のコマンドを実行
script/plugin install git://github.com/technoweenie/rest...
script/plugin install git://github.com/timcharper/role_r...
** セットアップ [#mab2b4d4]
- 次のコマンドを実行
./script/generate authenticated user sessions
./script/generate roles Role User
- Userは、authenticatedに指定したモデルクラス名
- Roleは、権限をあらわすモデル名
- 次のファイルが作らる
test/fixtures/users.yml
test/fixtures/roles.yml
app/models/role.rb
lib/role_requirement_system.rb
lib/role_requirement_test_helper.rb
lib/hijacker.rb
db/migrate/20100111002832_create_roles.rb
- テーブルを作る
rake db:migrate
- 次のテーブルができた
-- roles
-- roles_users
** 使い方 [#e34f21f2]
- rolesとusersはhabtmの関係
- rolesには「name」というカラムがあるだけ
- rolesに「admin」「user」などの値を持つレコードをいれて...
- コントローラー内に宣言的に記述
-- このコントローラーのすべてのアクションはadmin権限が必要
require_role "admin"
-- このコントローラーのindexアクション以外はadmin権限が必要
require_role "admin", :for_all_except => :index
-- このコントローラーのindexアクションはadmin権限が必要
require_role "admin", :for => :index
-- このコントローラーのすべてのアクションは「admin」と「e...
require_role "admin"
require_role "executive"
-- このコントローラーのすべてのアクションは「admin」と「e...
require_role "admin"
require_role "executive", :except => [:index]
-- このコントローラーのすべてのアクションは「admin」権限...
require_role "admin"
require_role "executive", :only => [:create, :update, :...
-- このコントローラーのすべてのアクションは「admin」権限...
require_role ["admin", "executive"]
-- このコントローラーの「list」アクションと「show」アクシ...
require_role "admin", :except => [:list, :show]
-- このコントローラーの「delete」アクションと「edit」アク...
require_role "admin", :only => [:delete, :edit]
- current_userに指定されたroleが紐づいていれば、要求され...
- 紐づいていなければ AuthenticatedSystemのaccess_denied ...
** 常に「admin」というroleの人はなんでも許可されるように...
- デフォルトでそうなっている
- app/model/user.rbに次のメソッドが追加されるているため
def has_role?(role_in_question)
@_list ||= self.roles.collect(&:name)
# return true if @_list.include?("admin") #This is the ...
(@_list.include?(role_in_question.to_s) )
end
#blikifooter(志田)
tag: [[Ruby on Rails>tag/Ruby on Rails]]
ページ名:
アークウェブのサービスやソリューションはこちら
サービス
Webの企画・戦略立案
Webデザイン
Webシステム開発
Zen Cartソリューション
Zen Cart導入コンサルティング, RFP作成, トラブル診断
Zen Cartで大規模ECサイト構築
Zen Cartモジュールの開発・カスタマイズ
Zen Cart制作会社(デザイン・企画会社)様向けサービス
Zen Cart海外向け・多言語ECサイトの制作
Zen Cartのデザイン, ペルソナ/シナリオ法, RIA(Ajax・Flex)
Zen Cartのセキュリティ・運用保守サポート
Zen Cart企画・マーケティング戦略, SEO・SEM(サーチエンジン広告)
Zen Cartハイエンド版(大規模サイト用高可用バージョン)
EC-CUBEとZen Cart 機能比較表(概要)
Zen Cart携帯モジュール(モバイルショップ構築用)
Zen Cartの導入事例
Zen-Cart.JPのご紹介とアークウェブの取り組み
Zen-Cartモバイルショップ構築サービス
Movable Typeソリューション
企業サイトでのMovable Type活用
Movable Type用プラグイン一覧
MT用フォーム作成プラグイン「A-Form」
A-Formパートナー制度
その他ソリューション
AjaxでRIA開発
Ruby on Rails
Flexによる業務システム構築
ペルソナ/シナリオ法
ビジネスブログ
SNS・ソーシャルソフトウェア
SEO・SEM
アークウェブのCSR(企業の社会的責任)
アークウェブのCSR指針