Skip to content

Commit

Permalink
Restore 'determine collection from model more conservatively...' - b5…
Browse files Browse the repository at this point in the history
  • Loading branch information
timblack1 committed Oct 3, 2012
1 parent 93b1556 commit 52d81b2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions backbone-couchdb.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,16 @@ Backbone.couch_connector = con =
# jquery.couch.js adds the id itself, so we delete the id if it is in the url.
# "collection/:id" -> "collection"
_splitted = _name.split "/"
_name = if _splitted.length > 0 then _splitted[0] else _name
_name = _name.replace "/", ""

# only pop off the last component if it is the id
if (_splitted.length > 0)
if (model.id == _splitted[_splitted.length - 1])
_splitted.pop()
_name = _splitted.join('/')

# remove any leading slash
if (_name.indexOf("/") == 0)
_name = _name.replace("/", "")
_name

# default local filter which selects documents of a given collection
Expand Down

0 comments on commit 52d81b2

Please sign in to comment.