Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
curiousyogurt opened this issue Jul 10, 2011 · 2 comments
Closed
Milestone

Comments

@curiousyogurt
Copy link

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
Copy link
Author

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
Copy link
Collaborator

gunn commented Jul 11, 2011

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants