{"action":"closed","issue":{"url":"https://api.github.com/repos/nathanvda/cocoon/issues/467","repository_url":"https://api.github.com/repos/nathanvda/cocoon","labels_url":"https://api.github.com/repos/nathanvda/cocoon/issues/467/labels{/name}","comments_url":"https://api.github.com/repos/nathanvda/cocoon/issues/467/comments","events_url":"https://api.github.com/repos/nathanvda/cocoon/issues/467/events","html_url":"https://github.com/nathanvda/cocoon/issues/467","id":271060290,"number":467,"title":"Not able to retrieve the some value in EDIT view","user":{"login":"Aravin","id":4869265,"avatar_url":"https://avatars0.githubusercontent.com/u/4869265?v=4","gravatar_id":"","url":"https://api.github.com/users/Aravin","html_url":"https://github.com/Aravin","followers_url":"https://api.github.com/users/Aravin/followers","following_url":"https://api.github.com/users/Aravin/following{/other_user}","gists_url":"https://api.github.com/users/Aravin/gists{/gist_id}","starred_url":"https://api.github.com/users/Aravin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aravin/subscriptions","organizations_url":"https://api.github.com/users/Aravin/orgs","repos_url":"https://api.github.com/users/Aravin/repos","events_url":"https://api.github.com/users/Aravin/events{/privacy}","received_events_url":"https://api.github.com/users/Aravin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2017-11-03T17:38:08Z","updated_at":"2017-11-07T18:29:16Z","closed_at":"2017-11-07T18:29:16Z","author_association":"NONE","body":"I am able to save the data using Cocoon. However, in edit view, I am not getting some values into textbox.\r\n\r\nI know, it's not cocoon issue. but please provide me any suggestion/idea.\r\n\r\n---\r\n### Controller\r\nnew\r\n`@invoice.invoice_items.build` \r\n\r\ncreate\r\n`@invoice.save` \r\n\r\n-- it will save in 3 tables - invoices, invoice_items, items\r\n\r\nedit\r\n`@invoice = Invoice.find(params[:id])`\r\n\r\n-- I am not able to retrieve the values from items values and show it in the textbox. Other fields are populated.\r\n\r\n---\r\n\r\n### Models\r\n\r\nInvoice\r\n\r\n```\r\nhas_many :invoice_items, inverse_of: :invoice, dependent: :destroy\r\n```\r\n\r\nInvoiceItem\r\n\r\n```\r\nbelongs_to :invoice\r\nbelongs_to :item\r\n```\r\nItem\r\n\r\n_nothing..._\r\n\r\n### Output\r\nAfter some workaround, I can get IDs of item table using `@invoice.invoice_items.map(&:item_id)`\r\n\r\nIf I pass the same in dropdown box, only first item gets selected.\r\n`<% item = options_for_select(item_hash, @invoice.invoice_items.collect(&:item_id)) %>`\r\n\r\n\r\n### In HTML\r\n\r\n2 Times this will occurs\r\n```\r\n<option value=\"4\">Item 1</option>\r\n<option value=\"5\" selected=\"selected\">Item 2</option>\r\n<option value=\"6\">Movie Tikcet</option>\r\n<option value=\"7\" selected=\"selected\">Test</option></select>\r\n```\r\nSee item 5 and 7 both are selected becuased invoice contain that both item. \r\n\r\n**So, I want first item should be selected 5 and second item should be 7 and so on..**"}}
{"actor":{"display_login":"Aravin"}}