Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't seem to use type as a property name #92

Closed
visoft opened this issue Jun 11, 2015 · 5 comments
Closed

Can't seem to use type as a property name #92

visoft opened this issue Jun 11, 2015 · 5 comments

Comments

@visoft
Copy link
Contributor

visoft commented Jun 11, 2015

My model has a string property called type, however when using make and passing in { type: 'foo' }, I get "Error: No model was found for 'foo'". Is there a workaround to this?

@danielspaniel
Copy link
Collaborator

ooo .. that is kind of a weak point. I was hoping no one would use that as an attribute ( like with rails where they reserve that property name 'type' for use when using polymorphic models.
Do you have to use that property name? Can you convince the database to change itself real quick? ( joking ) .. but if you can switch that .. it would be easiest ( duh ) .. because I can't think off the top of my head how I am going to change that internally.

@visoft
Copy link
Contributor Author

visoft commented Jun 12, 2015

I'll see what I can do about changing it. In the meantime, hopefully you can come up with a solution :)

@danielspaniel
Copy link
Collaborator

@visoft ... there is a solution ( 99% sure ) , but it means you would flag that there are no polymorphic relationships on your models. where you can set a flag in the test environment that looks something like ENV.APP.FACTORY_GUY_NO_POLYMORPHIC_MODELS = true
to disable that use of the type field in FactoryGuy to determine the type of a model.

Let me know if that would work for you.

@visoft
Copy link
Contributor Author

visoft commented Jun 14, 2015

That would work awesome.

@danielspaniel
Copy link
Collaborator

Version 1.1.0 fixes this issue, and no funny business needed ( ENV.APP.FACTORY_GUY_NO_POLYMORPHIC_MODELS ) just works as is. Thanks for pushing me to fix this @visoft , because it showed me a flaw in my model definitions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants