acts_as_taggable_on tag_list input custom form

14 views
Skip to first unread message

Jerome Lanteri

unread,
Aug 7, 2018, 10:34:06 PM8/7/18
to SimpleForm
Hi,
I use Simple_form gem and acts_as_taggable_on.
I have a Rails-5.2 model "Article" who has tags like:

class Article < ApplicationRecord
  acts_as_ordered_taggable_on
:interests
end

When i make the form like:

f.input :interest_list

inside the field, i have all the tags, but without comma separation between tags.
That is annoying because user have to, all the time, add it again, if not, many tags become one big tag when update.

So i was thinking to implement my own custom input with simple_form, but the only one page i see (the github simple_form wiki about input cutomization) is not to much instructive (or i not really understand how to implement something different than example shown).

Could you help me to understand which data inputs is need and how to work with for construct a custom input ?

final result should be:

f.input :interest_list, as: :tags

and should show tags list separate with: 1 comma and 1 space char:
tag 1, tag2, tag3

interest_list give an array of tags: => [tag1,tag2,tag3]

I think it should have something to do with
out<< @builder.text_field(attribute_name.join(", "), input_html_options)
but not... i have an error:
undefined method 'join' for interest_list:Symbol

who show that i absolutely not understand how to create a custom input simple_form.

Maybe then, when i will know/understand how to do, i should be happy to share my knowledge by add an other one example and also write a wiki paragraph i hope to be more instructive on the same custom input wiki official page.
Reply all
Reply to author
Forward
0 new messages