Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4826

How Ember knows which URL to hit in the backend?

$
0
0

@belgoros wrote:

I can’t figure out what is the convention rule in the when querring in model hook in a route handler. How Ember knows which URL to hit in the following situation:

Here is my router definition:

#router.js
Router.map(function() {
 ...
  this.route('languages', { path: '/shops/:shop_id/languages'});
});

Here the link definition in a template:

#application.hbs
{{#link-to 'languages' currentUser.user.shop.id class="nav-link"}}...{{/link-to}}

Here the route handler:

#languages.js

export default Route.extend(AuthenticatedRouteMixin, {
  model(params) {
    return this.store.query('language', { shop: params.shop_id })
  }
});

I hoped that Ember to hit shops/:shop_id/languages URL, but it did /languages?shop=6449 instead. Can somebody explain me the role of language String in this.store.query('language', { shop: params.shop_id }), - I belived that Ember would just deserialize language model (defined in models/language.js). Thank you.

Posts: 6

Participants: 4

Read full topic


Viewing all articles
Browse latest Browse all 4826

Trending Articles