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

Using 'url' as a property name in a model #15

Closed
brianberlin opened this issue Sep 4, 2014 · 5 comments
Closed

Using 'url' as a property name in a model #15

brianberlin opened this issue Sep 4, 2014 · 5 comments
Labels

Comments

@brianberlin
Copy link

When you create a model and try to use url in the list of props, an error is thrown when you try to save it.

Error: A "url" property or function must be specified

If you set the url it of coarse changes the url in which the model is saved.

model.save({ url: 'http://google.com' });
XMLHttpRequest cannot load http://google.com/.

Since url is a common field name used in databases I expected to be able to use it in an ampersand model.

Here is a simplified example: http://requirebin.com/?gist=2372c9322f4d2f5d5c3a

@v4l3nt1n
Copy link

We are having the same issue around here, our object from the api contains an 'url' property.

The issue is that if we use the 'url' inside the props definition of the model, then the url() function is never defined, so when you do fetch(), save(), etc, throws 'Error: A "url" property or function must be specified'.
And if you call the function myModel.url() from the console you get the undefined is not a function error.
Unfortunately its not a option for us to change the model's properties names, we already have our REST API working.

Thanks!

@brianberlin
Copy link
Author

This might help getting data into your ampersand models.
http://ampersandjs.com/docs#ampersand-state-parse

@v4l3nt1n
Copy link

Thanks brian, that should work as a workaround!

@webmasterkai
Copy link

Related/duplicate issue AmpersandJS/ampersand-collection-rest-mixin#3

@bear bear added the bug label Oct 30, 2014
@HenrikJoreteg
Copy link
Member

Hi folks! Sorry this has been sitting so long. Closing as a dupe of AmpersandJS/ampersand-collection-rest-mixin#3

Workaround is to either re-name it in using parse and serialize.

JGAntunes pushed a commit to sinfo/eventdeck that referenced this issue Nov 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants