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

  • Home
  • SEARCH
  • 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 6332785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:21:00+00:00 2026-05-24T18:21:00+00:00

cancan did not work with a controller that did not have a class. So

  • 0

cancan did not work with a controller that did not have a class. So I created the userhome.rb model:

class Userhome
end

There is an action in the userhome controller that accesses a page in another directory/class. An attempt to access it yields the following error:

undefined method `find' for Userhome:Class

Is the best thing for me to do…:

  1. delete the userhome model, and
  2. remove “load_and_authorize_resource” from the userhome controller, and
  3. just lock the application down with cancan in every other area possible?

Or is there a workaround to deal with this error?

  • 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-24T18:21:01+00:00Added an answer on May 24, 2026 at 6:21 pm

    Take a look at the CanCan documentation on non-RESTful controllers.

    A “resource” is the “thing” that your controller is responsible for listing, creating, updating, etc. It often is a model, but need not be (e.g. you might have a “search results” resource that doesn’t have a corresponding model).

    If your controller really isn’t dealing with a resource, then you may want to just use authorize! as appropriate within the controller, but if the controller is dealing with a resource but there is no corresponding model (which sounds like it may describe your situation) then you may want to use authorize_resource and specify that there is no corresponding class. This lets you “pretend” that you have a resource (i.e. you can specify abilities based on actions on a resource) without actually having a model that represents that resource.

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

Sidebar

Related Questions

I have installed devise. I did, rails g cancan:ability This is the Ability class
CanCan behaves really strange with index action in controller while using InheritedResouces. If i
I'm running into problems defining user permissions in my cancan controller: class Ability include
I have a problem using a method defined on a model in CanCan abilities:
My ability model looks something like this: class Ability include CanCan::Ability def initialize(user) if
I have a rails app with a CanCan 'role' model. Role has a name
I'm trying to restrict access to Projects that a user did not create. This
I am trying to get cancan to work with a polymorphic association, i have
I have a Column(Fields) that contain multiple values for each entity (One to Many).
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.