Hi there,
I have two models and controllers: Snippets, and Tags.
There is a belongs_to relationship, with tags belonging to snippets. This works well, I have a text field which creates a new tag associated with the snippet when the user submits a snippet.
I want to be able to have a text field which, when submitted to a function (in the model) would split the text on commas (e.g. split(",")
).
However, I'm having a little trouble with it.
My though process was, def a function on the Snippet model that splits the input then loops the array of the split, creating a new Tag associated with the Snippet at save time.
Sounds easy enough, but with the RoR magic it's just not happening for me :)
Can someone shed some light / link to a document or something - would be grand!!
Using rails3 with ruby 1.9.2 - normally PHP dev but giving this ruby a go. Magic.