Problem annotating Polymorphic Association #1

anithri opened this Issue Jun 1, 2012 · 2 comments


None yet
2 participants

anithri commented Jun 1, 2012

I got an error when it attempted to annotate a model used by other models as a polymorphic association

  A ServiceList#id [integer, primary, not null, limit=4]
  A ServiceList#service_id [integer, limit=4]
FAILURE while trying to update model ServiceList:
  uninitialized constant ServiceList::Service

For a model that looks like

class ServiceList < ActiveRecord::Base
  belongs_to :service, :polymorphic => true
  has_and_belongs_to_many :service_types

With a schema of:

create_table "service_lists", :force => true do |t|
  t.integer  "service_id"
  t.string   "service_type"
  t.boolean  "removed",      :default => false
  t.boolean  "accepted",     :default => false
  t.boolean  "read_only",    :default => false
  t.string   "subtype"
  t.integer  "project_id",                      :null => false
  t.datetime "created_at",                      :null => false
  t.datetime "updated_at",                      :null => false

Love everything else about this gem though. Thanks!

comboy closed this in ad6de85 Jun 1, 2012


comboy commented Jun 1, 2012

Thanks for reporting this issue :)

Indeed I missed that case when adding automatic belongs to descriptions.
I think it may be cleaner to display just association name instead of related class, and this should also fix the problem with polymorphic associations. I'm at the euruko conference right now so I just pushed this quick change and I'll try to push new gem version as soon as I get back or have some time (along with a bit of code cleanup), as for now, using master should work for you.

I'm keeping this issue open because tests are missing for polymorphic association case.

comboy reopened this Jun 1, 2012

anithri commented Jun 1, 2012

Installed from master, and it fixed the missing annotations right up. Thanks for the quick response!

comboy closed this in 67d1d1b Jun 4, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment