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.
Rails 3: has_many through controller action
-
28-06-2022 - |
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?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow