{"action":"created","issue":{"url":"https://api.github.com/repos/activeadmin/activeadmin/issues/4548","repository_url":"https://api.github.com/repos/activeadmin/activeadmin","labels_url":"https://api.github.com/repos/activeadmin/activeadmin/issues/4548/labels{/name}","comments_url":"https://api.github.com/repos/activeadmin/activeadmin/issues/4548/comments","events_url":"https://api.github.com/repos/activeadmin/activeadmin/issues/4548/events","html_url":"https://github.com/activeadmin/activeadmin/issues/4548","id":167213396,"number":4548,"title":"has_many creation fails on current master. Works on pre4","user":{"login":"djpate","id":512939,"avatar_url":"https://avatars.githubusercontent.com/u/512939?v=3","gravatar_id":"","url":"https://api.github.com/users/djpate","html_url":"https://github.com/djpate","followers_url":"https://api.github.com/users/djpate/followers","following_url":"https://api.github.com/users/djpate/following{/other_user}","gists_url":"https://api.github.com/users/djpate/gists{/gist_id}","starred_url":"https://api.github.com/users/djpate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djpate/subscriptions","organizations_url":"https://api.github.com/users/djpate/orgs","repos_url":"https://api.github.com/users/djpate/repos","events_url":"https://api.github.com/users/djpate/events{/privacy}","received_events_url":"https://api.github.com/users/djpate/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-07-24T02:27:02Z","updated_at":"2016-08-06T19:16:46Z","closed_at":null,"body":"I tried using the current master to my project.\r\n\r\nI have a has_many form such as.\r\n\r\n```\r\nf.inputs do\r\n    f.has_many :product_sub_categories do |psc|\r\n      psc.input :sub_category, :include_blank => false\r\n      psc.input :_destroy, as: :boolean\r\n    end\r\nend\r\n```\r\n\r\nThis form works fine on 0.6 and 1.0.0.pre4 but  on current master it fails to create because of duplicate key constraint on my model.\r\n\r\nI put a breakpoint in data_acces.rb in the save_model method and my object for some reason was created with two identical sub categories even though the params sent to the controler were fine (only one).\r\n\r\n```\r\nStarted POST \"/admin/products\" for 127.0.0.1 at 2016-07-23 19:12:44 -0700\r\n  ActiveRecord::SchemaMigration Load (2.6ms)  SELECT `schema_migrations`.* FROM `schema_migrations`\r\nProcessing by Admin::ProductsController#create as HTML\r\n  Parameters: {\"utf8\"=>\"✓\", \"authenticity_token\"=>\"7C/cAwEUuR0uC2nKP9DD5M0I/tcdntNF7lxnw08OgmTyRSyZI+Xe95EVdf8pTaKh77X2oTAguA6QWCOpO5HlOw==\", \"product\"=>{\"title\"=>\"ddoo\", \"description\"=>\"fooo\", \"image\"=>#<ActionDispatch::Http::UploadedFile:0x00000007cf19b0 @tempfile=#<File:/tmp/RackMultipart20160723-10866-7qvkqr.jpg>, @original_filename=\"evan dessin-8.jpg\", @content_type=\"image/jpeg\", @headers=\"Content-Disposition: form-data; name=\\\"product[image]\\\"; filename=\\\"evan dessin-8.jpg\\\"\\r\\nContent-Type: image/jpeg\\r\\n\">, \"sku\"=>\"80\", \"price\"=>\"50\", \"reduced_price\"=>\"\", \"display_order\"=>\"100\", \"active\"=>\"1\", \"gender\"=>\"0\", \"color_ids\"=>[\"\", \"2\", \"3\"], \"size_ids\"=>[\"\", \"8\", \"9\"], \"product_sub_categories_attributes\"=>{\"0\"=>{\"sub_category_id\"=>\"1\", \"_destroy\"=>\"0\"}}}, \"commit\"=>\"Create Product\"}\r\n```\r\n\r\n\r\n```\r\n[3] pry(#<Admin::ProductsController>)> object.product_sub_categories\r\n=> [#<ProductSubCategory:0x00000007d03480\r\n  id: nil,\r\n  product_id: nil,\r\n  sub_category_id: 1>,\r\n #<ProductSubCategory:0x00000007bb6b18\r\n  id: nil,\r\n  product_id: nil,\r\n  sub_category_id: 1>]\r\n```\r\n\r\n\r\n```\r\n  SQL (0.3ms)  INSERT INTO `products` (`title`, `description`, `sku`, `price`, `gender`, `image_file_name`, `image_content_type`, `image_file_size`, `image_updated_at`, `slug`, `created_at`, `updated_at`) VALUES ('ddoo', 'fooo', '80', 50.0, 0, 'evan_dessin-8.jpg', 'image/jpeg', 1153135, '2016-07-24 02:12:48', 'ddoo-4d84df6c-29af-4aa0-9c1a-76b2922f9073', '2016-07-24 02:14:21', '2016-07-24 02:14:21')\r\n  SQL (0.7ms)  INSERT INTO `product_sub_categories` (`sub_category_id`, `product_id`) VALUES (1, 94)\r\n  SQL (0.4ms)  INSERT INTO `product_sub_categories` (`sub_category_id`, `product_id`) VALUES (1, 94)\r\n   (8.6ms)  ROLLBACK\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/activeadmin/activeadmin/issues/comments/238043935","html_url":"https://github.com/activeadmin/activeadmin/issues/4548#issuecomment-238043935","issue_url":"https://api.github.com/repos/activeadmin/activeadmin/issues/4548","id":238043935,"user":{"login":"railscard","id":1060422,"avatar_url":"https://avatars.githubusercontent.com/u/1060422?v=3","gravatar_id":"","url":"https://api.github.com/users/railscard","html_url":"https://github.com/railscard","followers_url":"https://api.github.com/users/railscard/followers","following_url":"https://api.github.com/users/railscard/following{/other_user}","gists_url":"https://api.github.com/users/railscard/gists{/gist_id}","starred_url":"https://api.github.com/users/railscard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/railscard/subscriptions","organizations_url":"https://api.github.com/users/railscard/orgs","repos_url":"https://api.github.com/users/railscard/repos","events_url":"https://api.github.com/users/railscard/events{/privacy}","received_events_url":"https://api.github.com/users/railscard/received_events","type":"User","site_admin":false},"created_at":"2016-08-06T19:16:46Z","updated_at":"2016-08-06T19:16:46Z","body":"Same issue. It seems after [this PR](https://github.com/activeadmin/activeadmin/pull/4426) we don't need `assign_attributes` in build_resource anymore"}}
{"actor":{"display_login":"railscard"}}