在我的應用程序中,有一個客戶端讓成員選擇瓶子和管理部分來管理使用相同模型的成員,瓶子,儲物櫃等,所以我想我的路由器應該是這樣的:Emberjs Complex Routing
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"
我知道管理下的資源將替換具有相同名稱的成員的資源。
什麼是最好的模式來解決這個問題?
我目前的解決辦法是將命名空間中的資源,這樣的(有點):
@.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", ->
有沒有更好的辦法?這樣可怕嗎?我一直在查找EMBER.NAMESPACE,但我不明白我將如何使用它。
在GitHub上相關討論:
https://github.com/emberjs/ember.js/issues/683 https://github.com/emberjs/ember.js/pull/1925