views:

146

answers:

1

I have a Deals controller and I have an action called popular. I have added the popular to the routes (as a collection, if it's worth the info) and I want everybody to be able to acess that page.

I'm using CanCan and I have this:

class Ability
  include CanCan::Ability

  def initialize(user)
     user ||= User.new
     alias_action [:index, :show, :search, :recent, :popular], :to => :coolread

     can :read, :all
     can :coolread, :all

       #more stuff here but anyway

  end

end

The problem is that I get a CanCan::AcessDenied exception and I have no idea why. Can someone help me?

Thanks,

Nicolás Hock Isaza

A: 

Post your controller code. The issue may lie in that code. Also check out my blog post about using CanCan with devise if that's your setup: http://www.tonyamoyal.com/2010/07/28/rails-authentication-with-devise-and-cancan-customizing-devise-controllers/

Tony
It turned out to be a small code bug. It seems that the actions that are above other actions get overwritten. So I just changed the order of the ability definitions and it worked out.Thanks anyway :-)
Hock