I am relatively new to Rails, so please forgive me if this proves to be a rather naive question .:]
I have two models that can be tagged: Collection and Video . I support this with the Tag model with polymorphic association and has_many :through association with Tagging . This all works great.
What I find difficult to determine is how to set up the views for this. I know that if I only created or updated tags that are uniquely associated with one model, I could use a simple form and add accepts_nested_attributes_for to my model, but the problem I am facing is that I want to check first tag is present and only create it if it does not exist, otherwise just attach the existing tag to a new video or collection. Obviously, I could do this manually in the controller, but since Rails provides a mechanism for creating and updating related objects automatically, I wondered if it provided something like this to link existing objects?
Also, I'm not sure if I should embed the tags resource and process it centrally in the TagsController , or should I manage the tags from an object management object like VideosController .
Any help or advice is appreciated.
javascript ruby ruby-on-rails activerecord forms
Mic Pringle Jun 02 '16 at 2:43 on 2016-06-02 14:43
source share