1
votes

OK I started with this question: RnR: Database normalization, rails models and associations

I've set up the models as outlined. I'm trying to use the Rails_admin gem for the data maintenance. The issue is every polymorphic child table gives the following error:

    undefined method `klass' for nil:NilClass

However the parent record for location shows up, with fields for the associations in the list, but I cannot edit them. I was thinking maybe seed data would help, but I'm not sure what the format for the object_type should be? Is it case-sensitive, singular or plural?

2
Rails-admin and active-admin are both a real pain when trying to do stuff like this, are you sure your nested form is set up correctly? - TomDunning
Can you post the code for 2 of the models, controllers and the results of rake routes? - shutdown_r_now

2 Answers

1
votes

Figured it out, was using the same name for the association between two different polymorphic associations...

0
votes

object_type is formatted exactly like the model name.

Let's assuming you have Comments which can belong to either Articles or Posts, and our polymorphic association is commentable (thus, commentable_type and commentable_id).

A comment for Article with id 1 would be

commentable_type = 'Article'

commentable_id = 1