1

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?

Community
  • 1
  • 1
Ross R
  • 387
  • 1
  • 5
  • 21
  • 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 Aug 11 '12 at 18:17
  • Can you post the code for 2 of the models, controllers and the results of rake routes? – port5432 Aug 13 '12 at 17:56

2 Answers2

1

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

Ross R
  • 387
  • 1
  • 5
  • 21
0

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

Alfred
  • 21,058
  • 61
  • 167
  • 249
jbarket
  • 882
  • 7
  • 14