Search code examples
ruby-on-railsangularjsrestangular

Use Restangular with custom RubyOnRails controller action


On my rails app, I have the following route:

POST /api/patients/:id/update_weights(.:format) api/patients#update_weights {:format=>:json}

I'd like to post data from my angular app to my rails app so as update_weights action triggers. I would like to send the following data: {"param1" : "value", "param2" : "value", "param3" : "value"}

Does anyone know how to do this with Restangular?


Solution

  • Here is the solution I used:

    update: (id, param1, param2, param3) ->
      Restangular.one("patients", id)
                 .post("update_weights" ,{param_1: param1, param_2: param2, param_3: param3})