Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Regression bug v1.6.9 on polymorphic associations #825

javinto opened this Issue · 3 comments

3 participants

Javinto Steven Petryk xhoy


I have a polymorphic relationship in AR class Client like so: belongs_to :monitorable, :polymorphic=>true

In release 1.6.8 this works
can :manage, Client, {:monitorable=>{:person_people=>{:target_id=>, :person_relation_type_id=>}}}

In release 1.6.9 the above line of code will generate an error:

uninitialized constant Monitorable
activesupport (3.2.12) lib/active_support/inflector/methods.rb:230:in `block in constantize'

Steven Petryk

This is a known caveat in the way CanCan handles polymorphic associations. See this article on StackOverflow and the wiki.


H'm, I tried anything from the article and wiki in my ClientsController but with no luck. My client is called directly (no nested resource).

I finally managed like this:
load_and_authorize_resource :client, :parent=>true, :only=>[:index]
load_and_authorize_resource :client, :parent=>false, :except=>[:index]

There is no parent, but the index needs it. Why?
All other actions refuse to use the parent.

As my previous code "load_and_authorize_resource :client, :parent=>false" worked for all actions, I stick with it that something has broken in 1.6.9.


Thanks for your submission! The ryanb/cancan repository has been inactive since Sep 06, 2013.
Since only Ryan himself has commit permissions, the CanCan project is on a standstill.

CanCan has many open issues, including missing support for Rails 4. To keep CanCan alive, an active fork exists at cancancommunity/cancancan. The new gem is cancancan. More info is available at #994.

If your pull request or issue is still applicable, it would be really appreciated if you resubmit it to CanCanCan.

We hope to see you on the other side!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.