Undefined method `quoted_table_name' (Possible Polymorphic issue?) #537

Closed
curiousyogurt opened this Issue Jul 10, 2011 · 2 comments

3 participants

@curiousyogurt

I'm getting an error when I try to delete a record from my Users model (and almost the same one if I try to edit a record). The Users model includes the following:

has_many :user_tokens
has_many :invitees, :class_name => self.class.name, :as => :invited_by
has_many :messages, :dependent => :delete_all, :order => "created_at ASC"
has_many :alliances, :dependent => :delete_all

The error is:

undefined method `quoted_table_name' for Class:Class

With line 11 in _delete_notice.erb cited. Here is the extracted source:

10: <% @abstract_model.has_many_associations.each do |association| %>
11: <% object.send(association[:name]).reject{|child| child.nil?}.each do |child| %>

And here is the gist of the full trace: https://gist.github.com/1074184

I'm wondering whether this is a polymorphic issue, since there is no problem deleting records from Messages, for example.

Any help would be greatly appreciated. Thank you.

@curiousyogurt

I think I may have solved the problem. In order to avoid the conflict between Devise Invitable and rails_admin, I added this to the User model:

  has_many :invitees, :class_name => self.class.name, :as => :invited_by

This solved the NoMethodError, but created the above problem. I managed to solve the second problem by changing this line (just quoted above) to:

  has_many :invitees, :class_name => "User", :as => :invited_by

I'm still testing it out, but it seems to work.

@gunn
Collaborator

has_many :invitees, :class_name => self.name, :as => :invited_by should do the same.

@bbenezech bbenezech closed this Sep 5, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment