Skip to content

ActionView::TemplateError: Mysql::Error in production environment #6

@ian

Description

@ian

We're getting an interesting situation where a specific series of relationships produces an unknown column error in production only.

Consider the following:
class User < ActiveRecord::Base
has_many_polymorphs :accessible_products, :through => :accessibles, :as => :contact,
:foreign_key => 'contact_id', :foreign_type_key => 'contact_type',
:polymorphic_key => 'owner_id', :polymorphic_type_key => 'owner_type',
:from => [:"product/one",:"product/two"]
end

                 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions