In my application there is a client side for members to select bottles and an admin section to manage members, bottles, lockers etc. that both use the same models so I figured that my my router should look like this:
App.Router.map ->
@.route "signin" #Restuarant signs in to the application
@.resource "member", ->
@.route "signin" #Members sign in to see their bottles
@.resource "member", path: ":member_id", ->
@.resource "bottles", ->
@.route "select"
@.resource "transcations", ->
@.route "create"
@.resource "transcation", path: ":transcation_id", ->
@.resource "admin", ->
@.route "signin" #Restaurant signs in to manage
@.resource "members", ->
@.route "create"
@.resource "member", path: ":member_id", ->
@.resource "bottles", ->
@.route "create"
@.resource "bottle", path: ":bottle_id", ->
@.route "edit"
@.resource "transcations", ->
@.resource "transcation", path: ":transcation_id", ->
@.resource "lockers", ->
@.route "create"
@.resource "locker", path: ":locker_id", ->
@.resource "lockertype", path: "types", ->
@.resource "lockertype", path: ":locker_type_id", ->
@.route "edit"
@.route "create"
I understand that the resources under admin will replace the resources for the members that have the same name.
What would be the best pattern to solve this?
My current solution would be to namespace (kinda?) the resources like this:
@.resource "member", ->
@.route "m.signin" #Members sign in to see their bottles
@.resource "m.member", path: ":member_id", ->
@.resource "m.bottles", ->
@.route "select"
@.resource "m.transcations", ->
@.route "create"
@.resource "m.transcation", path: ":transcation_id", ->
Is there a better way? Is this way terrible? I've been looking up EMBER.NAMESPACE but I don't understand how I would use it.
Relevant discussions on github:
https://github.com/emberjs/ember.js/issues/683 https://github.com/emberjs/ember.js/pull/1925