{"action":"created","issue":{"url":"https://api.github.com/repos/trailblazer/reform/issues/454","repository_url":"https://api.github.com/repos/trailblazer/reform","labels_url":"https://api.github.com/repos/trailblazer/reform/issues/454/labels{/name}","comments_url":"https://api.github.com/repos/trailblazer/reform/issues/454/comments","events_url":"https://api.github.com/repos/trailblazer/reform/issues/454/events","html_url":"https://github.com/trailblazer/reform/issues/454","id":318994926,"node_id":"MDU6SXNzdWUzMTg5OTQ5MjY=","number":454,"title":"Nested form, two levels deep","user":{"login":"domi91c","id":5838941,"node_id":"MDQ6VXNlcjU4Mzg5NDE=","avatar_url":"https://avatars0.githubusercontent.com/u/5838941?v=4","gravatar_id":"","url":"https://api.github.com/users/domi91c","html_url":"https://github.com/domi91c","followers_url":"https://api.github.com/users/domi91c/followers","following_url":"https://api.github.com/users/domi91c/following{/other_user}","gists_url":"https://api.github.com/users/domi91c/gists{/gist_id}","starred_url":"https://api.github.com/users/domi91c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domi91c/subscriptions","organizations_url":"https://api.github.com/users/domi91c/orgs","repos_url":"https://api.github.com/users/domi91c/repos","events_url":"https://api.github.com/users/domi91c/events{/privacy}","received_events_url":"https://api.github.com/users/domi91c/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-04-30T18:50:16Z","updated_at":"2018-07-10T08:10:05Z","closed_at":null,"author_association":"NONE","body":"I had my Reform form working with one nested model, but I need that model to contain another nested model. A tutorial has_many steps, a step has_many images. Here's my attempt:\r\n```\r\nclass TutorialForm < Reform::Form\r\n\r\n  collection :steps, populator: :step_populator! do\r\n    property :title\r\n    property :body\r\n    validates :title, presence: true\r\n    validates :body, presence: true\r\n    collection :images, populator: :image_populator! do\r\n      property :image\r\n      validates :image, presence: true\r\n    end\r\n  end\r\n\r\n  def step_populator!(collection:, index:, **)\r\n    if (item = collection[index])\r\n      item\r\n    else\r\n      collection.insert(index, Step.new)\r\n    end\r\n  end\r\n\r\n  def image_populator!(collection:, index:, **)\r\n    if (item = collection[index])\r\n      item\r\n    else\r\n      collection.insert(index, Image.new)\r\n    end\r\n  end\r\nend\r\n```\r\n\r\nIs this totally wrong? It's not working at the moment."},"comment":{"url":"https://api.github.com/repos/trailblazer/reform/issues/comments/403737795","html_url":"https://github.com/trailblazer/reform/issues/454#issuecomment-403737795","issue_url":"https://api.github.com/repos/trailblazer/reform/issues/454","id":403737795,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMzczNzc5NQ==","user":{"login":"unrooty","id":26375494,"node_id":"MDQ6VXNlcjI2Mzc1NDk0","avatar_url":"https://avatars1.githubusercontent.com/u/26375494?v=4","gravatar_id":"","url":"https://api.github.com/users/unrooty","html_url":"https://github.com/unrooty","followers_url":"https://api.github.com/users/unrooty/followers","following_url":"https://api.github.com/users/unrooty/following{/other_user}","gists_url":"https://api.github.com/users/unrooty/gists{/gist_id}","starred_url":"https://api.github.com/users/unrooty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unrooty/subscriptions","organizations_url":"https://api.github.com/users/unrooty/orgs","repos_url":"https://api.github.com/users/unrooty/repos","events_url":"https://api.github.com/users/unrooty/events{/privacy}","received_events_url":"https://api.github.com/users/unrooty/received_events","type":"User","site_admin":false},"created_at":"2018-07-10T08:10:05Z","updated_at":"2018-07-10T08:10:05Z","author_association":"NONE","body":"@apotonick when I wrote p form.contacts[0].phones, I got \r\n```\r\n[#<#<Class:0x00007f00f265f000>:0x00007f0117da22c0 @fields={\"number\"=>\"648-822-8073\", \"type\"=>\"Work\", \"primary\"=>true}, @model=#<ContactPhone id: 12, number: \"648-822-8073\", type: \"Work\", contact_id: 12, created_at: \"2018-07-07 12:10:37\", updated_at: \"2018-07-07 12:10:37\", primary: true>, @mapper=#<#<Class:0x00007f0127d8a688>:0x00007f0117da2180 @model=#<ContactPhone id: 12, number: \"648-822-8073\", type: \"Work\", contact_id: 12, created_at: \"2018-07-07 12:10:37\", updated_at: \"2018-07-07 12:10:37\", primary: true>>, @_changes={}, @errors=#<Reform::Form::ActiveModel::Errors:0x00007f0117da1de8 @base=#<#<Class:0x00007f00f265f000>:0x00007f0117da22c0 ...>, @messages={}, @details={}>>]\r\n```\r\nBut when I tried to pass it to ff.fields_for, I've got error:\r\n```\r\nundefined method `number' for #<Disposable::Twin::Collection:0x00007f0117da1ca8>\r\n```\r\nAnother thing that I want to say is that after ```||``` I build model if it doesn't exists."}}
{"actor":{"display_login":"unrooty"}}