Last active
December 20, 2015 04:29
-
-
Save vanstee/6070992 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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