Question

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])
  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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top