activeadmin_addons icon indicating copy to clipboard operation
activeadmin_addons copied to clipboard

Tags input submits a string instead of an array

Open heaven opened this issue 4 years ago • 2 comments

"tag_names"=>"Awesome,Test,Test 123"

The form field is defined like this:

f.input :tag_names, label: "Tags", as: :tags, collection: Tag.all.pluck(:name)

And inside the model I have:

def tag_names=(*names)
  self.tags = Tag.find_or_create_by_names(*names)
end

def tag_names
  self.tags.pluck(:name)
end

heaven avatar Feb 20 '21 11:02 heaven

I'm new to this gem but why don't you do

f.input :tag_ids, label: "Tags", as: :tags, collection: Tag.all

vccoffey avatar Jul 14 '21 21:07 vccoffey

@vccoffey the input is in the tags mode, which enables you to add new tags on the fly.

heaven avatar Aug 17 '21 20:08 heaven