Im pretty new at ember and I want to make Route work with a string instead of id for a prettier url. This Router code here is working when I enter the path manually example.com/#/Commune. But when using {{#linkTo "commune" name}}{{name}}{{/linkTo}} the url is changing correctly but nothing is showing (it does if i refresh the browser). any idea?
JS:
App.Router.map(function() {
this.route('commune', {path: "/:commune_name"});
});
App.CommuneRoute = Em.Route.extend({
model: function(params) {
return App.CommunesController.findProperty('name', params.commune_name);
}
});
If I do this: it's the other way around. (links working but enter/refresh aint)
App.CommuneRoute = Em.Route.extend({
model: function(params) {
return App.Commune.find(params.commune_name);
}
});
params.commune_name
is set correctly? also, isCommuneRoute
really your only route? (just wondering because of theCommunesController
.) – Finn MacCoolApp.Router.map(function() { this.route('commune', {path: "/:commune_id"}); }); App.CommuneRoute = Em.Route.extend({ model: function(params) { return App.Commune.find(params.commune_id); } });
its the other way around, now the liks is working but on enter/refresh it crashes – Thomas Carlsenreturn App.Commune.find({name: params.commune_name});
(or maybereturn App.Commune.find({'name': params.commune_name});
) in yourCommuneRoute
with the old router? – Finn MacCool