开发者

inherited_resources and cancan conflict

There are conflict with inherited_resources and Ryan Bates's cancan gem.

I have some simple controller

class IssuesController < InheritedResources::Base
  respond_to :html

  load_and_authorize_resource

  def tag
    @issues = Issue.tagged_with(params[:tag]).recent.paginate(:page => params[:page])
 开发者_StackOverflow end

  protected

  def collection
    @issues = end_of_association_chain.recent.paginate(:page => params[:page], :per_page => Settings.per_page_defaults.issues)
  end
end

and route

  resources :issues do
    collection do
      get "tag/:tag" => "issues#tag", :as => "tags"
    end
  end

Everything looks correct, but on attempt to request http://localhost:8080/issues/tag/tag1 i see

 ActiveRecord::RecordNotFound in IssuesController#tag

Couldn't find Issue without an ID

After removing load_and_authorize_resource from controller - everything works fine, but i need access control.

Any idea how to solve this issue?


use load_and_authorize_resource :except => :tag. Note that this wont apply rules. If you need to apply some use authorize! instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜