Last active
August 29, 2015 14:02
-
-
Save merqlove/ccdc89cd7e54266e82c3 to your computer and use it in GitHub Desktop.
Angular $resource experience with Rails based API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create service for our factories. Don't blow .json extension. This is easiest path to get JSON request in AUTO mode. | |
angular.module("identityService", ["ngResource"]) | |
.factory 'Identity', ($resource) -> | |
$resource '/api/v1/identities/:id.json', | |
{ id:'@id' } | |
# Added update via PUT | |
@identities.config ($resourceProvider) -> | |
$resourceProvider.defaults.actions.update = { method: 'PUT' } | |
# Run our test | |
@identities.controller 'RestaurantIndexCtrl', ($scope, Identity) -> | |
data = { | |
identity: { | |
user_id: 55 | |
provider: "vkontakte" | |
} | |
} | |
Identity.save(data) | |
Identity.update id:1, identity: {user_id:444} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment