{"action":"created","issue":{"url":"https://api.github.com/repos/nathanvda/cocoon/issues/469","repository_url":"https://api.github.com/repos/nathanvda/cocoon","labels_url":"https://api.github.com/repos/nathanvda/cocoon/issues/469/labels{/name}","comments_url":"https://api.github.com/repos/nathanvda/cocoon/issues/469/comments","events_url":"https://api.github.com/repos/nathanvda/cocoon/issues/469/events","html_url":"https://github.com/nathanvda/cocoon/issues/469","id":274194654,"number":469,"title":"Create 2 has_many through associations in one Cocoon form","user":{"login":"clveranis","id":26399853,"avatar_url":"https://avatars3.githubusercontent.com/u/26399853?v=4","gravatar_id":"","url":"https://api.github.com/users/clveranis","html_url":"https://github.com/clveranis","followers_url":"https://api.github.com/users/clveranis/followers","following_url":"https://api.github.com/users/clveranis/following{/other_user}","gists_url":"https://api.github.com/users/clveranis/gists{/gist_id}","starred_url":"https://api.github.com/users/clveranis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clveranis/subscriptions","organizations_url":"https://api.github.com/users/clveranis/orgs","repos_url":"https://api.github.com/users/clveranis/repos","events_url":"https://api.github.com/users/clveranis/events{/privacy}","received_events_url":"https://api.github.com/users/clveranis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-11-15T15:22:24Z","updated_at":"2017-11-16T02:34:08Z","closed_at":null,"author_association":"NONE","body":"Hey guys,\r\n\r\nI've asked this question on [Stack Overflow](https://stackoverflow.com/questions/47216904/create-2-has-many-through-associations-in-one-cocoon-form) first, as recommended because I know GH issues are more for problems with Cocoon rather than how-to-help, but its approaching a week with no responses and in my experience that usually means the question is dead.\r\n\r\nEither way, I'm wondering if its possible to tell Cocoon to create a second association on a has_many through relationship. I've broken down the specifics in my SO post. I picked through the core Cocoon code and see that it uses the `create_object_on_association` method which I'm assuming creates both the object as well as the association. So is there a way to make it so I can create a second association with a different model for the same new object I'm creating?\r\n\r\nI understand it probably will be a custom method or modifying the current one but I wanted to see if you guys had any ideas so I'm not shooting in the dark. \r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/nathanvda/cocoon/issues/comments/344796705","html_url":"https://github.com/nathanvda/cocoon/issues/469#issuecomment-344796705","issue_url":"https://api.github.com/repos/nathanvda/cocoon/issues/469","id":344796705,"user":{"login":"clveranis","id":26399853,"avatar_url":"https://avatars3.githubusercontent.com/u/26399853?v=4","gravatar_id":"","url":"https://api.github.com/users/clveranis","html_url":"https://github.com/clveranis","followers_url":"https://api.github.com/users/clveranis/followers","following_url":"https://api.github.com/users/clveranis/following{/other_user}","gists_url":"https://api.github.com/users/clveranis/gists{/gist_id}","starred_url":"https://api.github.com/users/clveranis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clveranis/subscriptions","organizations_url":"https://api.github.com/users/clveranis/orgs","repos_url":"https://api.github.com/users/clveranis/repos","events_url":"https://api.github.com/users/clveranis/events{/privacy}","received_events_url":"https://api.github.com/users/clveranis/received_events","type":"User","site_admin":false},"created_at":"2017-11-16T02:34:08Z","updated_at":"2017-11-16T02:34:08Z","author_association":"NONE","body":"Hey Mirv, thank you for taking the time to comment. \r\n\r\nIn plain English, upon creation of a single new object (owners) I want to add it to two associated models (property&order) that already exist at the time of creating the owner.\r\n\r\nI understand what you're staying in the demo workflow you typed out, however, it's slightly different than what I'm trying to accomplish. It would be more along the lines of\r\n\r\n    ### this is for demo only and is not a literal translation of any code ### \r\n\r\n    @order = Order.find(1)\r\n    @property = Property.find(1)\r\n    (@property.orders << @order) # adding this just to show relationship\r\n\r\n    # when filling out an order I add an owner via forms & Cocoon, so lets say step 1:\r\n    @order.owners << owner1\r\n\r\n    # and in essence my next step would be, step 2:\r\n    @orders.owners.each do |owner|\r\n      @property.owners << owner\r\n    end\r\n\r\n    # so at the end of the whole thing, it would be like this:\r\n    @owner.owners = owner1\r\n    @property.owners = owner1 \r\n\r\nSo the entire point to all this is just to add a single new record, to two models, the same way as in your demo app would be adding \r\n\r\n    Project <- Project_tags <- Tag1\r\n    Job <- Job_tags <- Tag1\r\n\r\nI apologize if this whole thing got convoluted with information overload and if this is not possible to do with Cocoon then I understand. In laymans terms, I don't understand how the method `create_object_on_association` does what it does and I'm just trying to do that x2. "}}
{"actor":{"display_login":"clveranis"}}