maccman/spine — Issue #157: Spine.Model.Ajax - @url() fails when adding parameter (code attached)
Author: gbrits
Created: 2011-12-09 20:29:07+00:00
State: open

According to http://spinejs.com/docs/ajax:
assertEqual( Photo.url("order"), "/photos/order" )

This isn't correct, since @url() doesn't take any param in this implementation, see Ajax.coffee line 164:

url: ->
base = "#{Model.host}/#{@className.toLowerCase()}s"
base

Instead the method could be something like this (just started in coffee, so it can probably be shortened)

url: (path)->
base = "#{Model.host}/#{@className.toLowerCase()}s"
if path
base += '/' unless base.charAt(base.length - 1) is '/'
base += encodeURIComponent(path)
base

Note that I don't run my stuff with node.js (instead with Play Framwork Coffee-module which uses Rhino for automated builds under the cover) but I don't think that matters. I couldn't test the actual assertEqual( Photo.url("order"), "/photos/order" ) for that reason, because that's a native node.js module afaik, which I couldn't locate for inclusion in my setup

hth,
Geert-Jan