Based on a lot of resources found on the internet, i'm trying to create my custom model action which sends a POST /api/v1/users/subscribe
request. My code looks like this:
@UserModel = Backbone.Model.extend
urlRoot: '/api/v1/users'
subscribe: (opts) ->
url = "#{@urlRoot}/subscribe"
options =
url: @url
method: 'POST'
_.extend @options, opts
return (@sync or Backbone.sync).call this, null, this, @options
However, when using it as follows:
user = new UserModel
user.subscribe()
It make s a GET /api/v1/users
request. Can you please explain me what is wrong with my code? Almost all examples about custom methods looks like this: https://gist.github.com/sap1ens/4692429 and my code is an exact port of it.
Thanks in advance