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

Warnings for incorrect options in belongsTo, resolves #3187 #3226

Merged
merged 1 commit into from
Jun 11, 2015
Merged

Warnings for incorrect options in belongsTo, resolves #3187 #3226

merged 1 commit into from
Jun 11, 2015

Conversation

zoeesilcock
Copy link
Contributor

Display a warning when the user specifies serialize or embedded in the options for belongsTo. These settings belong in the serializer now, I have linked to the relevant documentation pages in order to help the user to do what they meant to do. Resolves #3187.

@@ -93,6 +93,14 @@ function belongsTo(modelName, options) {

opts = opts || {};

if (opts.hasOwnProperty('serialize')) {
Ember.warn('You provided a serialize option, this belongs in the serializer. See DS.Serializer and it\'s implementations http://emberjs.com/api/data/classes/DS.Serializer.html');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you tell the user for which model they provided it, that would make the warning much less confusing. Something like: In the modelName class, passed a serialize option to the belongsTo relationship key. You most likely want to be configuring that in the serializer...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I'll change the error message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @igorT, I can't figure out how to provide the information you mentioned. I can only get ahold of the modelName which is the name of the model that the relationship is to. I can't find the name of the model or the property on where the belongsTo was used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you move the warning into the getter, you should be able to do this. Perf isn't as important as anything inside Ember.warn/assert etc. gets stripped in production

igorT added a commit that referenced this pull request Jun 11, 2015
Warnings for incorrect options in belongsTo, resolves #3187
@igorT igorT merged commit 354c6d7 into emberjs:master Jun 11, 2015
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

Successfully merging this pull request may close these issues.

2 participants