acts-as-taggable-on icon indicating copy to clipboard operation
acts-as-taggable-on copied to clipboard

Doesn't save tags passed as associations after upgrading to 6.0.0

Open Hirurg103 opened this issue 7 years ago • 11 comments

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!

Hirurg103 avatar Aug 10 '18 10:08 Hirurg103

I am upgrading from 5.00 to 6.00 version and I have the same issue.

How did you solve it @Hirurg103 ?

piotr-galas avatar Mar 19 '19 17:03 piotr-galas

Hi @piotr-galas I could not solve this issue for now and use the 5 version

Hirurg103 avatar Mar 19 '19 19:03 Hirurg103

@Hirurg103 override tagging model in you app with this file

uzaif313 avatar Apr 07 '19 14:04 uzaif313

@Hirurg103
You have added the optional: true to this file. I will prepare PR with this fix, in the next week maybe

piotr-galas avatar Apr 08 '19 08:04 piotr-galas

Hi @piotr-galas. I suppose you wanted to mention @uzaif313 in your last comment

Hirurg103 avatar Apr 08 '19 19:04 Hirurg103

thanks, @Hirurg103 for fix @piotr-galas comment

uzaif313 avatar Apr 14 '19 08:04 uzaif313

Any update on this? just started running into this issue.

DRBragg avatar Aug 09 '19 15:08 DRBragg

some question

Guoxweii avatar Aug 26 '19 08:08 Guoxweii

i use the patch but not work, error is there

jackbit avatar Aug 31 '19 19:08 jackbit

Don't specify config.load_defaults <rails_v>

in application.rb

sajjadmurtaza avatar Jan 04 '21 12:01 sajjadmurtaza

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

moritzschepp avatar Nov 04 '21 08:11 moritzschepp