2007-06-18から1日間の記事一覧

ActsAsRolePermittable 拡張 (1)

ロールベースに基づいたパーミッション設定が可能なモデルを作っています。 実際の使用イメージ。 class SecureModel < ActiveRecord::Base acts_as_role_permittbale # point 0 end model = SecureModel.create(...) # 基本 # モデルに対して "index" とい…

ActsAsRolePermittable 拡張(4)

Actsの実装コードですが、先に、WjRolePermissionKeys#roles と WjRolePermissionKeys#permit? だけ片付けられそうですね。 # あとで書く で、WjComponentPage#permit_roles やら、permit? やらを acts_as_role_permittable に実装しにいきます。 大抵は、wj…

ActsAsRolePermittable 拡張(3)

テストクラスを書きます。使用例とテーブル設計から察するに、model.role_permissions("index") は WjRolePermissionKey クラスのオブジェクトになるはずですですから、roles=(val), permit?(user)のテストケースが必要でしょう。(anonymous=はActiveRecord…

ActsAsRolePermittable 拡張 (2)

パーミッションを保持するテーブルは次のようになります。 | wj_roles | <<--->> | wj_role_permissionn_keys | --> |acts_as_role_permittable classs|ここで、-->> は 1:N の関係を表現しています。> は N:N掬(hbtm)です。

たまには汎用的に役立つ記事を

tips タグには、開発中に覚えた技を。。。他にも転用できそうなものの中から*1。 *1:切り出して、公開しろという話ですが、それは面倒くさいので気が向いたら。。。