Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7171413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:24:35+00:00 2026-05-28T15:24:35+00:00

CanCan behaves really strange with index action in controller while using InheritedResouces. If i

  • 0

CanCan behaves really strange with index action in controller while using InheritedResouces. If i have

can :read, Question do |question|
  false
end

in ability.rb – it grants access to the action despite on block’s returning value. If i remove this line – “You are not authorized to access this page.”.
Controller code below:

# encoding: utf-8
class QuestionsController < InheritedResources::Base
  actions :all, :except => [:edit, :update]

  before_filter :authenticate_user!,  :except => [:show]
  load_and_authorize_resource         :except => [:show]
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:24:36+00:00Added an answer on May 28, 2026 at 3:24 pm

    I’m not really sure but try with:

    class QuestionsController < InheritedResources::Base
      actions :index, :new, :create, :destroy, :show
      ...
    

    There was a bug some time ago with :except. https://github.com/railsbp/rails_best_practices/issues/66.

    Try updating InheritedResources gem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two entities. User and Role. I am using Devise and CanCan. They
My setup: Rails 3.0.9, Ruby 1.9.2 I am using Cancan to authorize a controller
I'm using Cancan to control User abilities, and have recently run into an odd
I'm using cancan as my authorization engine. I already have the roles in user:
I have a problem using a method defined on a model in CanCan abilities:
Using RSpec and Cancan, I have this test which fails with: Failure/Error: User.should_receive(:new).and_return(@user) expected:
cancan did not work with a controller that did not have a class. So
I am using cancan for authorization. I have a shared view which need authorize
I'm using devise and cancan in a Rails 3.2 project. I have an event
I have looked at declarative_authorization, CanCan, and CanTango. They all are good in adding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.