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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:17:52+00:00 2026-05-26T23:17:52+00:00

I am using cancan and trying to get it to limit equipment shown for

  • 0

I am using cancan and trying to get it to limit equipment shown for a specific company.

I have a company with many users that should only see equipment that belong to that company.

I thought cancan could do this based on this:

Rails 3 company account with many users, restrict access to data

So I tried this code:

can :manage, Equipment do |equipment|
  user.company == equipment.company
end

In the equipment controller I have @equipment = Equipment.all which I figured would just pull the equipment for that users company, but of course it pulls them all. Is there an easy way to do this or do I need to do @equipment = Equipment.find_by_company_id(current_user.company) anytime I want to pull just that companies equipment. To make this worse I want to eventually break it down by groups and departments, but would rather not have to force myself into more big find queries. I am open to anything, plugins, suggestions, whatever will be the fastest way to fix this.

I could have added more code to this question, but I don’t know that adding it all would really help the question.

Thank you very much

Toby

  • 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-26T23:17:53+00:00Added an answer on May 26, 2026 at 11:17 pm

    Try Equipment.accessible_by()

    https://github.com/ryanb/cancan/blob/master/lib/cancan/model_additions.rb

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

Sidebar

Related Questions

I'm trying to get some basic authentication/authorization with devise/cancan with Rails. Rather than using
I have a rails app that is is using cancan permission and i am
I am trying to implement specific object (row) authorisation using cancan, I want it
I'm working on a Rails app using CanCan for RBAC and I only have
I am using rails 3 with cancan gem.And now i am trying to implement
I have two entities. User and Role. I am using Devise and CanCan. They
Hello I'm actually using Ryan' Bates cancan gem authorization to make my application's users
Building a rails B2B application that will have various users. I'm pretty clear on
I am trying to test a CanCan ability in my app that also uses
I'm trying to incorporate Devise and Cancan into a web app. I want users

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.