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 6785355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:06:59+00:00 2026-05-26T17:06:59+00:00

I have tried every way possible and can’t seem to limit the scope_to method

  • 0

I have tried every way possible and can’t seem to limit the scope_to method in active_admin using cancan.

I can get the menu to play nice as well as most other methods but not scope_to

For example this works fine:

menu :if => proc{ can?(:manage, Booking) }

But not

scope_to :current_user, :association_method => :space_bookings unless proc{ can?(:manage, Booking) }

or

scope_to :current_user, :association_method => :space_bookings unless proc{ current_user.admin? }

or

scope_to :current_user, :association_method => :space_bookings unless controller.current_ability.can?( :manage, config.resource )

If I try using the current_user method without proc I get an error undefined. The current_user method is defined by devise and also in the active_admin.rb

  # == Current User
  #
  # Active Admin will associate actions with the current
  # user performing them.
  #
  # This setting changes the method which Active Admin calls
  # to return the currently logged in user.
  config.current_user_method = :current_user

Any ideas how I can gain access to the current_user method? It works everywhere else I’ve needed it.

  • 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-26T17:07:00+00:00Added an answer on May 26, 2026 at 5:07 pm

    Accessing methods, even those in the application_controller within active_admin can often be painful.

    But you can skip it entirely by rewriting the controller explicitly, it’s not ideal, but it works.

     controller do 
      #  authorize_resource
        def index
          if can? :manage, :all
            @bookings = Booking.page params[:page] #you must call .page for the index to work.
          else
            @bookings = current_user.bookings.page params[:page]
          end
          index! #this is needed unless you are using custom views
        end 
      end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Over the years, I think I have seen and tried every conceivable way of
Possible Duplicate: Can I have multiple background images using CSS? Is it possible to
I have searched and tried every example regarding singleton, public, and global variables in
Hi i want to apply style on every 2nd <li> i have tried <script>
Have tried to find solutions for this and can't really come up with anything.
Well I tried to figure out is this possible in any way. Here is
Ok I have been trying every which way to figure this out. I need
Have you ever tried learning a language while on a project? I have, and
Have anybody ever tried to create thumbnails/previews of MS Office files? I do not
I have tried unsuccessfully to copy the pwd to pbcopy as follows pwd |

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.