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

AATO 6.0.X does not work with new records

Open michelson opened this issue 6 years ago • 5 comments

Hi, I've found that in the recent version of this gem (6.0.x) when you instantiate a new record or call .build on collection association the tagging is not properly saved because the taggable is blank and then the record that acts as taggable cant be saved either

      expect(event.save).to be_truthy # saves ok
      # kind is the AATO and participable_kinds is the acts_as_taggable_on :participable_kinds
      event.participations.build(participable: user, participable_kinds: [kind])
      expect(event.save).to be_truthy # fails with active record errors on tags

the error on event instance is @details={:"participations.participable_kind_taggings"=>[{:error=>:invalid}]},

it seems the participation instance can't be saved because the tagging triggered a validation error and the tagging is not saved because taggable_id is blank, because the participation is not saved ....

this spec was green on previous version of AATO . I just upgraded because i'm upgrading to rails 5.2 from rails 4.2 with the AATO 3.5.0 version

michelson avatar Jul 17 '18 01:07 michelson

I can confirm that the spec above pass if I set: optional:true belongs_to :taggable, polymorphic: true, optional: true in the Tagging class of the gem

michelson avatar Jul 17 '18 02:07 michelson

Please merge!

coneybeare avatar Oct 06 '18 19:10 coneybeare

Are there any efforts to merge this in near future?

robotex82 avatar Mar 10 '19 17:03 robotex82

@robotex82 you can use: gem "acts-as-taggable-on", git: "https://github.com/michelson/acts-as-taggable-on" in your gemfile to get master branch

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

updated for rails 6.1

michelson avatar Apr 02 '21 17:04 michelson