pdbradley
(Philip Bradley)
August 18, 2015, 9:59pm
5
I just want to report on what what causing us such a nightmare.
We would do @order.becomes !(MediaMailOrder).save
and at various times it would work, and at others not, and no real logic to it that we could find.
Eventually I found this post related to the paper_trail gem. The version of the gem we were using goes in and touches the type field on the model for some reason. When I disabled paper trail everything worked as expected. I think. I’m so tired I need to look at it again tomorrow. We spent quite a bit of time on this one.
If we upgrade our paper_trail we should be okay.
opened 02:29AM - 31 Jul 14 UTC
closed 06:11PM - 02 Mar 15 UTC
I've run into this weird issue running Rails 4.1.4 and paper_trail 3.0.3. Ill tr… y and simplify my code to explain what is happening.
```
class Page < ActiveRecord::Base
class Draft < ActiveRecord::Base
include PaperTrail
has_paper_trail
end
end
class MainPage < Page
class Draft < Page::Draft; end
end
class SubPage < MainPage
class Draft < MainPage::Draft; end
end
```
The page and page_drafts table both have the 'type' inheritance column. There are some instances where I need to change the type. Previously, I was able to do something like this:
```
my_page = MainPage::Draft.create
my_page.update type: 'SubPage::Draft'
```
The update call would then update the type and updated_at columns. When upgrading to Rails 4.1.4, the update call is only updating the updated_at field. I noticed that when removing paper_trail from the Page::Draft class, it works as expected.
The weird thing is that it seems to work as expected if my_page is an instance of the Page::Draft class where has_paper_trail is called. If my_page is an instance of a subclass of Page::Draft, thats when I notice this issue.
I apologize if this is hard to follow. I've been trying to use the template at https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_master.rb to create a failing test, but I am having issues getting PaperTrail included.
I originally thought this was an issue with Rails 4.1 until I discovered that removing PaperTrail fixed my issue. Reverting to Rails 4.0.8 and leaving in PaperTrail also fixes the issue. Any idea what could be going on?