I have this routes configuration and my ability don't work. It redirects to the root path. Why?
...
constraints subdomain: /^(?!www|secure|test|local)(\w+)/ do
namespace :channels, path: '' do
resource :profile
...
app/models/ability.rb
...
can :access, Channels::ProfilesController
...
The application controller has the _enableauthorization. And the profiles controller inherits from the base controller and the base controller from the application controller.
class Channels::ProfilesController < Channels::BaseController
...
def resource
@profile ||= channel
end
...
EDIT
Here an error using the console:
> Channel.accessible_by(ability)
CanCan::Error: The accessible_by call cannot be used with a block 'can' definition. The SQL cannot be determined for :index :channels
EDIT 2
If I write only this ability:
app/models/ability.rb
...
can :access, Channel
...
and test it with ability.can? i get:
2.0.0p247 :026 > ability.can?(:access, Channel)
=> false
2.0.0p247 :026 > Channel.accessible_by(ability)
Channel Load (1.2ms) SELECT "channels".* FROM "channels" WHERE ('t'='f')
Hi!
I have this routes configuration and my ability don't work. It redirects to the root path. Why?
app/models/ability.rb
The application controller has the _enableauthorization. And the profiles controller inherits from the base controller and the base controller from the application controller.
EDIT
Here an error using the console:
EDIT 2
If I write only this ability:
app/models/ability.rb
and test it with ability.can? i get:
What ist this WHERE ('t'='f')?