Access request params from query params within a route


#1

I’m trying to do this

export default Ember.Route.extend({   model: function(params) {
     this.store.query('workspace', {user: ':uid'});   }

});

And then I’m rewriting urlForQuery method in a RestAdapter so to build a url based on that parameter. The problem is when I’m accessing query.user in the adapter it would of course return ‘:uid’ whereas I need a value that this key represents. Is there any way to parse a value in RestAdapter having param key? Newer version of Ember does not allow to inject an end value rather dasherized param.


#2

Using this technique allows you to build up the query collection as you want it to be: // content of model(params)
let hash = {};
let uid = params.user;
if (uid) {
hash.user = uid;
}
return this.store.query(‘workspace’, hash);

Demoing code from a phone… !


Passing classes to store methods has been removed
#3

I can’t believe. It seems the issue was in json response from backend. The error message would not help at all:

Passing classes to store methods has been removed. Please pass a dasherized string instead of undefined Error: Assertion Failed: Passing classes to store methods has been removed. Please pass a dasherized string instead of undefined


#4

Hey can you elaborate a bit more on what was wrong with the returned JSON? I got the same error with nested models retrieved from my back-end. Thank you.


#5

JSON was wrong formatted. In fact it is well explained in the official start guide, but I ignored it. Check this reference with expected request/response json format explained: http://blog.embed.ly/post/50012690904/ember-at-embedly-tutorial-models-and-ember-data


#6

Since there is no clear information in this error anywhere on the internet, could you please take a look at my post. I just can’t figure out where this error comes from even with the information you provided me.


#7

The solution here was to use a serializer, worked for me!