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

Reference other fields in Factory.define #21

Open
tomyo opened this issue Aug 22, 2016 · 2 comments
Open

Reference other fields in Factory.define #21

tomyo opened this issue Aug 22, 2016 · 2 comments

Comments

@tomyo
Copy link

tomyo commented Aug 22, 2016

Hi, certain fields in my collection depend on other field values. How can a obtain the value of a field in definition?
Example:

Factory.define 'product', App.collections.products,
sex: -> getRandomElementFromList ['Male', 'Female']
category: -> # This value depends on the chosen sex value.

Thanks.

@dburles
Copy link
Collaborator

dburles commented Aug 23, 2016

Hey @tomyo you can reference other fields through the function context. e.g. this.sex

@tomyo
Copy link
Author

tomyo commented Aug 23, 2016

Awesome. :)
Thanks.

On Mon, Aug 22, 2016, 21:51 David Burles notifications@github.com wrote:

Hey @tomyo https://github.com/tomyo you can reference other fields
through the function context. e.g. this.sex


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#21 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AArP2bs0XphH2jndYZz5Yzwd0gMR4kDOks5qikQVgaJpZM4JqDGi
.

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