问题
I have a user model
and language model
where the language model contains list of languages and the user model contains the information of the user. In user model there is a field
called language
where the user should select a language from the language model. And for all these i do not have form and i want to pass the id
of the language when creating new user and it should save the language for the user. I use curl
to create and update.
So please tell me how i can do this? Please help me.
Thanks in advance.
回答1:
I think nested attribute is what you need. You can learn more about it here : Active Record Nested Attributes
Additionally for simulating nested attribute calls using curl, you can look at this post :
Simulate a form post with nested resources arrays using curl
来源:https://stackoverflow.com/questions/13680792/how-can-i-add-values-for-a-field-from-another-model-in-rails