{"action":"created","issue":{"url":"https://api.github.com/repos/activeadmin/activeadmin/issues/5445","repository_url":"https://api.github.com/repos/activeadmin/activeadmin","labels_url":"https://api.github.com/repos/activeadmin/activeadmin/issues/5445/labels{/name}","comments_url":"https://api.github.com/repos/activeadmin/activeadmin/issues/5445/comments","events_url":"https://api.github.com/repos/activeadmin/activeadmin/issues/5445/events","html_url":"https://github.com/activeadmin/activeadmin/issues/5445","id":348642578,"node_id":"MDU6SXNzdWUzNDg2NDI1Nzg=","number":5445,"title":"form.has_many cannot hide 'remove button' on new records","user":{"login":"omitter","id":17044127,"node_id":"MDQ6VXNlcjE3MDQ0MTI3","avatar_url":"https://avatars1.githubusercontent.com/u/17044127?v=4","gravatar_id":"","url":"https://api.github.com/users/omitter","html_url":"https://github.com/omitter","followers_url":"https://api.github.com/users/omitter/followers","following_url":"https://api.github.com/users/omitter/following{/other_user}","gists_url":"https://api.github.com/users/omitter/gists{/gist_id}","starred_url":"https://api.github.com/users/omitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omitter/subscriptions","organizations_url":"https://api.github.com/users/omitter/orgs","repos_url":"https://api.github.com/users/omitter/repos","events_url":"https://api.github.com/users/omitter/events{/privacy}","received_events_url":"https://api.github.com/users/omitter/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-08-08T09:19:08Z","updated_at":"2018-09-04T12:55:11Z","closed_at":null,"author_association":"NONE","body":"I pre-build the attributes of associated objects for a new object and don't won't the customers to change their count. That's why I need to remove the 'remove' button (and the 'add new' button, but that works fine). My code looks like this: `f.has_many :sub_model, allow_destroy: false, new_record: false`. Unfortunately this still generates the 'remove' buttons. I know, most of the time that is wanted, but when I explicitly pass `false` to the `allow_destroy`, I except them to disappear.\r\n\r\nI fixed this issue by patching the source in `activeadmin-1.3.0/lib/active_admin/form_builder.rb`:\r\nin `has_many_actions`:\r\n```ruby\r\n     if has_many_form.object.new_record?\r\n```\r\nto\r\n```ruby\r\n     if has_many_form.object.new_record? && builder_options[:allow_destroy] != false\r\n```\r\n\r\nIf there are no regressions, it would be great if you could add that upstream. Thanks for considering :)"},"comment":{"url":"https://api.github.com/repos/activeadmin/activeadmin/issues/comments/418355996","html_url":"https://github.com/activeadmin/activeadmin/issues/5445#issuecomment-418355996","issue_url":"https://api.github.com/repos/activeadmin/activeadmin/issues/5445","id":418355996,"node_id":"MDEyOklzc3VlQ29tbWVudDQxODM1NTk5Ng==","user":{"login":"chumakoff","id":4020700,"node_id":"MDQ6VXNlcjQwMjA3MDA=","avatar_url":"https://avatars1.githubusercontent.com/u/4020700?v=4","gravatar_id":"","url":"https://api.github.com/users/chumakoff","html_url":"https://github.com/chumakoff","followers_url":"https://api.github.com/users/chumakoff/followers","following_url":"https://api.github.com/users/chumakoff/following{/other_user}","gists_url":"https://api.github.com/users/chumakoff/gists{/gist_id}","starred_url":"https://api.github.com/users/chumakoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chumakoff/subscriptions","organizations_url":"https://api.github.com/users/chumakoff/orgs","repos_url":"https://api.github.com/users/chumakoff/repos","events_url":"https://api.github.com/users/chumakoff/events{/privacy}","received_events_url":"https://api.github.com/users/chumakoff/received_events","type":"User","site_admin":false},"created_at":"2018-09-04T12:55:11Z","updated_at":"2018-09-04T12:55:11Z","author_association":"CONTRIBUTOR","body":"No, sorry, I don't like the option 2. As I have already sad, the `:allow_destroy` option has it's own purpose and shouldn't be mixed with \"Remove new record\" logic. This is my opinion.\r\n\r\nYou should also keep in mind that not only boolean can be passed as the `:allow_destroy` option, but also String, Symbol, Proc.\r\n\r\nBy the way, using `Rails`'s `:fields_for` method instead of `Formtastic`'s `:inputs` will probably work for you. Try it.\r\n\r\n    f.fields_for :sub_models do ..."}}
{"actor":{"display_login":"chumakoff"}}