I would like to create form with text_fields
- TITLE
- CONTENT
- TAGS
I have Post (TITLE, CONTENT) and Tag (TAGS) model. TAGS is a single text field. What do I have to do to save TAGS to Tag model. Let say I write ‘banana, juice, new tag’ in the TAGS field, how can this be parsed into array and then save in the Tag model.
Thx!
Use a setter method in your model to do it.
Your view would look like this:
And then in your model you would have a model such as this:
Edit: As has been mentioned, there are plugins which do this for you, acts_as_taggable_on_steroids is a horribly named, but very effective option.