acts-as-taggable-on
acts-as-taggable-on copied to clipboard
Doesn't save tags passed as associations after upgrading to 6.0.0
Hello,
in our project we assign tags the following way:
tag = ActsAsTaggableOn::Tag.create! name: 'people'
Article.create! title: 'Title', content: 'Text', tags: [tag]
#or
Article.create! title: 'Title', content: 'Text', tags_ids: [tag.id]
Especially we have many pieces like this in our tests.
After upgrade from AATO 5.0.0 to 6.0.0 it started to fail with
ActiveRecord::RecordInvalid:
Validation failed: Tag taggings is invalid
Seems like that tagging cannot be saved because context is blank.
Should it save tags passed to tags association with DEFAULT_CONTEXT = 'tags' by default?
If it should could you please confirm and fix it, otherwise I need to change the way we assign tags in our code
Thank you!
I am upgrading from 5.00 to 6.00 version and I have the same issue.
How did you solve it @Hirurg103 ?
Hi @piotr-galas I could not solve this issue for now and use the 5 version
@Hirurg103 override tagging model in you app with this file
@Hirurg103
You have added the optional: true to this file. I will prepare PR with this fix, in the next week maybe
Hi @piotr-galas. I suppose you wanted to mention @uzaif313 in your last comment
thanks, @Hirurg103 for fix @piotr-galas comment
Any update on this? just started running into this issue.
some question
i use the patch but not work, error is there
Don't specify
config.load_defaults <rails_v>
in application.rb
You can also remove the validator for the taggable association:
# config/initializers/aato.rb
chain = ActsAsTaggableOn::Tagging.send(:get_callbacks, :validate)
callback = chain.find{|cb| cb.filter.attributes == [:taggable]}
chain.delete(callback)
Works on rails 5.1 with aato 7.0.0