Should `tag_names` be assignable on new?
kenips opened this issue · 11 comments
The current validation requires tagging
to have a valid belongs_to taggable
. This seems to prevent assigning tag_names
on new object, which is allowed by other libraries such as acts-as-taggable-on. Just wondering if this will be supported soon?
Hmm, hadn't thought of that approach. You're right that it definitely doesn't work with the current code... I'm not quite sure how to restructure things so it does, but I'm certainly open to that. Pull requests are welcome, but I'll leave this issue open so that if I have the time and a touch of inspiration I'll have a go.
This change is now published in 0.3.0. Thanks for logging the issue :)
Thank you very much! Interesting take actually - I thought you'd just be setting the taggable_id on create!
So @pat with
gutentag/lib/gutentag/active_record.rb
Line 15 in be449ca
Nope, that's getting evaluated within the class context (attar_writer is a class method) but it's creating the instance method tag_names=. Are you finding that's not the case?
Right, of course! No I was just trying to override tag_names= in my class (after calling has_many_tags. I guess in this case I need to alias not super. Just wasn't thinking straight.
Ah right - yup, because the method doesn't exist in any ancestor of the model, there's no super definition. Aliasing is definitely the way to go (which is a shame, super is far nicer).
... and now I'm thinking about ways to change the code so method inheritance is possible. Hmm.
Haha :). Yep especially when you peek into ancestors and the modules are there. Would be interested to know your process in converting it so!
ha! yes. thanks for everything.