We're getting an interesting situation where a specific series of relationships produces an unknown column error in production only.
class Product < ActiveRecord::Base
has_many_polymorphs :accessors, :through => :accessibles, :as => :owner,
:foreign_key => 'owner_id', :foreign_type_key => 'owner_type',
:polymorphic_key => 'contact_id', :polymorphic_type_key => 'contact_type',
:from => [:emails, :users]
end
class Accessible < ActiveRecord::Base
acts_as_double_polymorphic_join :owners =>[:"product/one",:"product/two"],
:contacts => [:users, :emails]
end
This cyclical relationship should be handled by the acts_as_double_polymorphic_join but it's erroring in production, possibly due preloading of models and caching them, not sure.
The error we receive in production is ActionView::TemplateError: Mysql::Error: Unknown column 'accessibles.accessible_product_id'
The foreign and polymorphic keys are clearly defined, not sure why this is happening and only in production.