What is the best way to implement Polymorphic Association in SQL Server?

Another common Name for this model is the Supertype Model, where one has a base set of attributes that can be expanded via joining to another entity. In Oracle books, it is taught both as a logical model and physical implementation. The model without the relations would allow data to grow into invalid state and … Read more

Why can you not have a foreign key in a polymorphic association?

A foreign key must reference only one parent table. This is fundamental to both SQL syntax, and relational theory. A Polymorphic Association is when a given column may reference either of two or more parent tables. There’s no way you can declare that constraint in SQL. The Polymorphic Associations design breaks rules of relational database … Read more

ActiveRecord, has_many :through, and Polymorphic Associations

There is a known issue with Rails 3.1.1 that breaks this functionality. If you are having this problem first try upgrading, it’s been fixed in 3.1.2 You’re so close. The problem is you’re misusing the :source option. :source should points to the polymorphic belongs_to relationship. Then all you need to do is specify :source_type for … Read more

how to generate migration to make references polymorphic

What you are trying to do is not yet implemented in the stable version of rails so Michelle’s answer is the right one for now. But this feature will be implemented in rails 4 and is already available in the edge version as follows (according to this CHANGELOG): $ rails generate migration AddImageableToProducts imageable:references{polymorphic} Some … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)