Skip to content

Instantly share code, notes, and snippets.

@vanstee
Last active December 20, 2015 04:29
Show Gist options
  • Select an option

  • Save vanstee/6070992 to your computer and use it in GitHub Desktop.

Select an option

Save vanstee/6070992 to your computer and use it in GitHub Desktop.
// Works but is pretty verbose
App.Router.map(function() {
this.route("users.index", { path: "/users" });
this.route("users.new", { path: "/users/new" });
this.route("user.index", { path: "/users/:user_nickname" });
this.route("user.edit", { path: "/users/:user_nickname/edit" });
});
// Seems to be the best way to use the DSL but the `:user_nickname` param is incorrectly replaced
App.Router.map(function() {
this.resource("users", { path: "/users" }, function() {
this.route("new");
});
this.resource("user", { path: "/users/:user_nickname" }, function() {
this.route("edit");
});
});
// user_index_route.js for reference
App.UserIndexRoute = Ember.Route.extend(
model: function(params) {
App.User.find(params.user_nickname)
},
serialize: function(model) {
{ user_nickname: model.get('nickname') }
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment