Declare type key on polymorphic belongs_to #414

Merged
merged 2 commits into from May 23, 2012

Conversation

Projects
None yet
2 participants
@md5
Contributor

md5 commented May 7, 2012

When a belongs_to association is marked as :polymorphic => true, add a model key of type String for the "type_key_name" field in addition to the key of type ObjectId for "foreign_key"

Mike Dillon and others added some commits May 7, 2012

Mike Dillon
Declare type key on polymorphic belongs_to
When a belongs_to association is marked as :polymorphic => true, a model
key of type String for the "type_key_name" field in addition to the key
of type ObjectId for "foreign_key"
@brianhempel

This comment has been minimized.

Show comment Hide comment
@brianhempel

brianhempel May 23, 2012

Contributor

@md5 @dillonm-digisynd Is there a specific issue you had that's solved by adding the type_key explicitly?

Contributor

brianhempel commented May 23, 2012

@md5 @dillonm-digisynd Is there a specific issue you had that's solved by adding the type_key explicitly?

@ghost

This comment has been minimized.

Show comment Hide comment
@ghost

ghost May 23, 2012

One of our projects uses a validation to ensure that only declared keys end up getting saved. In the case of these polymorphic mappings, the type key ends up undeclared. We've worked around it with a plugin, so we can live without the merge, but it makes sense to me to either declare both id and type keys or declare neither.

ghost commented May 23, 2012

One of our projects uses a validation to ensure that only declared keys end up getting saved. In the case of these polymorphic mappings, the type key ends up undeclared. We've worked around it with a plugin, so we can live without the merge, but it makes sense to me to either declare both id and type keys or declare neither.

brianhempel added a commit that referenced this pull request May 23, 2012

Merge pull request #414 from md5/declare-belongs_to-type-key
Declare type key on polymorphic belongs_to

@brianhempel brianhempel merged commit 28d005e into mongomapper:master May 23, 2012

@brianhempel

This comment has been minimized.

Show comment Hide comment
@brianhempel

brianhempel May 23, 2012

Contributor

Agreed, it makes sense. Thanks for the explanation. Merged.

Contributor

brianhempel commented May 23, 2012

Agreed, it makes sense. Thanks for the explanation. Merged.

@md5 md5 deleted the md5:declare-belongs_to-type-key branch Jan 16, 2013

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