将 Restangular 与自定义 RubyOnRails 控制器操作结合使用
Use Restangular with custom RubyOnRails controller action
在我的 rails
应用程序中,我有以下路线:
POST /api/patients/:id/update_weights(.:format) api/patients#update_weights {:format=>:json}
我想 post
从我的 angular
应用程序到我的 rails
应用程序的数据,以便 update_weights
动作触发。我想发送以下数据:
{"param1" : "value", "param2" : "value", "param3" : "value"}
有谁知道如何用 Restangular
做到这一点?
这是我使用的解决方案:
update: (id, param1, param2, param3) ->
Restangular.one("patients", id)
.post("update_weights" ,{param_1: param1, param_2: param2, param_3: param3})
在我的 rails
应用程序中,我有以下路线:
POST /api/patients/:id/update_weights(.:format) api/patients#update_weights {:format=>:json}
我想 post
从我的 angular
应用程序到我的 rails
应用程序的数据,以便 update_weights
动作触发。我想发送以下数据:
{"param1" : "value", "param2" : "value", "param3" : "value"}
有谁知道如何用 Restangular
做到这一点?
这是我使用的解决方案:
update: (id, param1, param2, param3) ->
Restangular.one("patients", id)
.post("update_weights" ,{param_1: param1, param_2: param2, param_3: param3})