I have a model, “note”, which has any number of tags. I want users to be
able to create tags within the same form as creating a note. I have that
part.
Where I’m lost is that I want to be able to type in a tag name, hit
enter, and have it added to a temporary list of tags which tracks the
tags that have been added to this note. So you go to write a note, fill
everything out, and type in a tag named, “ruby” the page is reloaded,
and “ruby” is now a saved tag. Type in another name, it’s saved, and
added to the list. Save the model and the list is saved as that models
tags.
I was hoping to do it by initializing a array in my “new” action. Of
course, that doesn’t work because the “create” action has no knowledge
of the variable. However, if I initialize the variable in the “create”
action, it’s set back to [] after I send the form. So the tag is saved,
but there’s no tag list.
Hopefully I got this across successfully. If anything’s unclear, please
ask me to correct it.
Thanks,
Adam