Is it possible to force an insert in paper trail table 'versions' without making the insert in the real table. I need to store a 'create' insert in the paper trails table so I can get the object after a confirmation, and just then, make the real insert.
Thanks
PaperTrail::Versions are just ActiveRecord objects, so you can instantiate and save them just like any of your models:
version = PaperTrail::Version.new
version.item = my_item
version.object = my_item
version.event = :create
version.save!
PaperTrail cannot store unsaved objects in its object
column, however - it gets saved as nil. This means that .object
will be nil
if you load this version record out of the DB.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.