question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set id property when defining a route

See original GitHub issue

Is it possible to set id property while defining a route? I know there is one global config, but each model I get from server has different property name for ID

Restangular.all('tenants');
// some way to set id value from 'tenantId' of the Tenant

Issue Analytics

  • State:open
  • Created 10 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
mgontocommented, Nov 15, 2013

You do have one more option.

In the new version, I actually expose the configuration so you could replace the function setIdToElem and getIdFromElem from Restangular.configuration or RestangularProvider.configuration.

setIdToElem: https://github.com/mgonto/restangular/blob/master/src/restangular.js#L197

getIdToElem: https://github.com/mgonto/restangular/blob/master/src/restangular.js#L202

Basically, what you could do is something like

RestangularProvider.configuration.getIdFromElem = function(elem) {
  // if route is tenants ==> returns tenantID
  return elem[_.initial(elem.route).join('') + "ID"];
}
0reactions
thueycommented, Aug 24, 2015

If this is known not to work with RestangularProvider (as seems to be the case in my experience), then the README is a bit misleading: https://github.com/mgonto/restangular#what-if-each-of-my-models-has-a-different-id-name-like-customerid-for-customer

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to pass id to React Js path link? - Stack Overflow
1 Answer 1 · Define your path to include an id <Route path="/products/:id"> <Products /> </Route> · On the products page use useParams...
Read more >
Routing to controller actions in ASP.NET Core - Microsoft Learn
Attribute routing provides fine-grained control to make the ID required for some actions and not for others. By convention, the documentation ...
Read more >
Manage Routes in a Route Set - Oracle Help Center
Search for Routes in a Route Set. You can search for routes in a route set by pub-id, SED, and other properties. You...
Read more >
How to use attribute routing in ASP.NET Core - InfoWorld
You can set up routing in ASP.NET Core in two different ways: attribute-based routing and convention-based routing.
Read more >
Defining Your Routes - Ember Guides
The default serialize method inserts the model's id into the route's dynamic segment (in this case, :post_id ). Initial routes. A few routes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found