Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/active_admin/form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class HasManyBuilder < SimpleDelegator
attr_reader :assoc
attr_reader :options
attr_reader :heading, :sortable_column, :sortable_start
attr_reader :new_record, :destroy_option
attr_reader :new_record, :destroy_option, :remove_option

def initialize(has_many_form, assoc, options)
super has_many_form
Expand Down Expand Up @@ -72,6 +72,7 @@ def extract_custom_settings!(options)
@sortable_start = options.delete(:sortable_start) || 0
@new_record = options.key?(:new_record) ? options.delete(:new_record) : true
@destroy_option = options.delete(:allow_destroy)
@remove_option = options.key?(:allow_remove) ? options.delete(:allow_remove) : true
options
end

Expand Down Expand Up @@ -105,7 +106,7 @@ def render_has_many_form(form_builder, parent, &block)
end

def has_many_actions(form_builder, contents)
if form_builder.object.new_record?
if form_builder.object.new_record? and remove_option
contents << template.content_tag(:li) do
template.link_to I18n.t('active_admin.has_many_remove'), "#", class: 'button has_many_remove'
end
Expand Down