Question

I've got a Rails 3 app setup that I use for driving an API, with a has_many through association working. I know that to setup the association I should use device.favourites.create(object) and that works fine when I run it either within the web app, or on the console but I don't know how I should use it for the controller action for a json request. Should I POST to the join model (Favourites) or one of the models at the end (Device/Store)? If I POST to the one of the models at either end, should I calling the .create method with controller create method?

Was it helpful?

Solution

I ended up just using the join model to accept a params hash containing both the variables it links against. It was the cleanest way to do it and it seems to work fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top