3

I'm working on a bug on a rails engine using both paper_trail and acts_as_taggable_on. When I rollback a deleted event the event details are restored, but the tags are not. Has anyone came across this same issue?

Some relevant info:

models/calagaor/event.rb

class Event < ActiveRecord::Base
  has_paper_trail
  acts_as_taggable 
end

I also created a config/initializers/act_as_taggable.rb file:

ActsAsTaggableOn::Tag.class_eval do
  has_paper_trail
end

ActsAsTaggableOn::Tagging.class_eval do
  has_paper_trail
end 

I'm pretty new to rails so I'm not sure if I'm headed in the right direction or not. Let me know if you need more details. Thanks!

Edit:

controllers/calagator/versions_controller.rb

module Calagator

class VersionsController < Calagator::ApplicationController
  def edit
    @version = PaperTrail::Version.find(params[:id])
    @record = @version.next.try(:reify) || @version.item ||    @version.reify

    singular =    @record.class.name.singularize.underscore.split("/").last
    plural = @record.class.name.pluralize.underscore.split("/").last
    self.instance_variable_set("@#{singular}", @record)

    if request.xhr?
      render :partial => "calagator/#{plural}/form", :locals => {   singular.to_sym =>  @record }
    else
      render "calagator/#{plural}/edit", :locals => { singular.to_sym =>  @record }
    end
  end
end

end

I'm using paper_trail '3.0.8'

alexandraleigh
  • 187
  • 1
  • 14

1 Answers1

1

[How do I use] paper_trail to reify acts_as_taggable_on associations? I'm using paper_trail '3.0.8'

paper_trail 3 doesn't do associations. Try upgrading to paper_trail 4.

Docs: https://github.com/airblade/paper_trail#associations

Jared Beck
  • 16,796
  • 9
  • 72
  • 97