質問

(免責事項:私は非常に新しいレール)

このプラグインのように見えまれに合ったアプリのかもしれませんが、同じ くできるのではないかと考えてます。を使用していまauthlogic、 という問題ですが、そうしたものであってもよい。

またアクセスページが私の管理者の役割へのアクセスを持つべきであるか この:

Processing CompaniesController#show (for 127.0.0.1 at 2010-02-12
23:26:44) [GET]
Parameters: {"action"=>"show", "id"=>"1", "controller"=>"companies",
"battalion_id"=>"1"}
User Load (0.000681)   SELECT * FROM "users" WHERE ("users"."id" =
'147') LIMIT 1
User Update (0.000622)   UPDATE "users" SET "perishable_token" =
'tUyTl1eZDQSJwp_PFw7c', "last_request_at" = '2010-02-13 05:26:44',
"updated_at" = '2010-02-13 05:26:44' WHERE "id" = 147
Role Load (0.000334)   SELECT * FROM "roles" WHERE ("roles".user_id
= 147)
Permission denied: No matching rules found for show for #<User id:
147, user_type: nil, login: "lauren_roth", name: "Lauren
Rothlisberger", email: "laurenrothlisber...@gmail.com",
crypted_password:
"d835a2cdf15ef449d0980e706fd86d7a9a7a0a23d0d79d6f18f...",
 password_salt: "_Qz_z8eZOhKHcsPsBsoP", created_at: "2010-02-12
 16:37:53", updated_at: "2010-02-13 05:26:44", old_remember_token: nil,
 old_remember_token_expires_at: nil, old_activation_code: nil,
 activated_at: nil, old_password_reset_code: nil, enabled: true,
 identity_url: nil, invitation_id: nil, invitation_limit: nil,
 position: "Admin", battalion_id: nil, company_id: nil, soldier_id:
 nil, login_count: 68, failed_login_count: 0, last_request_at:
 "2010-02-13 05:26:44", current_login_at: "2010-02-13 05:20:59",
 last_login_at: "2010-02-13 05:19:57", current_login_ip: "127.0.0.1",
 last_login_ip: "127.0.0.1", persistence_token:
 "28fc9b60853045cd4e43a001b4258940a7e8f9ac50b08df6a6d...",
 single_access_token: "bKgYvuRtLqauufljZDoV", perishable_token:
 "tUyTl1eZDQSJwp_PFw7c", active: true, platoon_id: nil> (roles
 [:Admin], privileges [:show], context :companies).
 Filter chain halted as [:filter_access_filter] rendered_or_redirected.
 Completed in 27ms (View: 1, DB: 0 3 queries) | 403 Forbidden [http://
 localhost/battalions/1/companies/1]

私はこの私のユーザーモデル def role_symbols 役割||[]).地図{|r|r.の名前です。to_sym} 終了

が見られるとは思えませんと呼ばれるようになりますよ.I 考え あなたの 心の問題かもしれませんが、同じものだが何もない のuser_sessions?

また、この私のapplication_controller次のように記述されています。

 helper_method :current_user_session, :current_user
 filter_parameter_logging :password, :password_confirmation

  before_filter :set_current_user
  protected
  def set_current_user
    Authorization.current_user = current_user
  end

  def current_user_session
    return @current_user_session if defined? (@current_user_session)
    @current_user_session = UserSession.find
  end

  def current_user
    return @current_user if defined?(@current_user)
    @current_user = current_user_session && current_user_session.record
  end

  def store_location
    session[:return_to] = request.request_uri
  end

  def redirect_back_or_default(default)
    redirect_to(session[:return_to] || default)
    session[:return_to] = nil
  end


Here is my authorization_rules.rb

かったのを活かし、管理することを反映:

authorization do
   role :guest do
    has_permission_on :user_sessions, :to => [:create, :update]
   end

   role :Admin do
     has_permission_on :companies, :to => [:index, :show]
   end
 end 

場合はそのアイデア私はいくてはならないものです。感謝。

役に立ちましたか?

解決

話を聞いてみると、どうやらアプリケーションのルールをテーブル 役割 適切な負荷のconfig/authorization_rules.rbのファイルを修正。をご確認くださいファイルの名前の構文を使用します。

利用するようにして、 特典 部署 authorization_rules.rb;このように:

privileges do
  privilege :manage, :includes => [:create, :read, :update, :delete]
  privilege :read, :includes => [:index, :show]
  privilege :create, :includes => :new
  privilege :update, :includes => :edit
  privilege :delete, :includes => :destroy
end

いつ、どの企業にコントローラ?


テレビでも展開しております。

他のヒント

  

私はそれを反映するために管理者を活用しました。

あなたはそれによって何を意味するのですか?管理者の役割がauthorization_rules.rbメソッドが動作しているようだとしてrole_symbolsファイルに大文字にする必要があり、ユーザーの役割の配列として[:Admin]を返しています。あなたは、ログにそれを見ることができます:

  

(roles [:Admin], privileges [:show], context :companies)

これは、現在のユーザーが指定した役割を持っていることを意味するが、コンテキスト/リソースにアクセスするためにリストされた権限の少なくとも一つを必要とします。だからあなたのauthorization_rules.rbは資産役割:Adminを持っている必要があります。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top