Skip to content

Adding dynamic segment to model's urls #417

Description

@gabriel-dehan

Hello !

I was looking for a way of having a dynamic part in my model's url. Something like this :

import Ember from "ember";

MyModel = Ember.Model.extend({
  // Relations and stuff
  some_resource: Ember.belongsTo("some-resource", { primaryKey:  'id' }),
});

MyModel.url = "/some_resource/:id/other_resource" // post/:id/comment for instance
MyModel.adapter = Ember.RESTAdapter.create();

export default MyModel;

But that does not work from the get go obviously. I thought of overwriting the buildURL function in my own adapter but we only get the record (before it's fetched, with nothing but a primary key) and I can't manage to get its belongsTo. Is there a built in way to do this or should there be one ?

Thanks !

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions