Unify 2 rails resources Angularjs

时间:2015-05-04 19:21:21

标签: javascript angularjs coffeescript angular-resource angularjs-rails

I have the next resource:

angular.module('app').factory 'User', [
  '$resource'
  ($resource) ->
    $resource '/users/:id/:action', {
      id: '@id'
      action: '@action'
    },
      query:
        method: 'GET'
        isArray: false
      'update':
        method: 'PUT'
        transformRequest: (data) ->
          JSON.stringify user: data
      'resetPassword':
        params: action: 'reset_password'
        method: 'PUT'
]

And I want to unify it with the next one:

angular.module('app').factory "NewUser", ["RailsResource", "railsSerializer", (RailsResource, railsSerializer) ->
  class NewUser extends RailsResource
    @configure
      url: '/users'
      rootWrapping: false
      serializer: railsSerializer ->
        @nestedAttribute "addresses", "address"
  NewUser
]

The goal is to have both of the above resources merged into a single one. What's the best approach for doing this?

0 个答案:

没有答案