I'm using the paper_trail (https://github.com/airblade/paper_trail) gem in my application for store versioning. I customize with class_name. I able to collect record through query but how to access object's data
ElementVersion(id: integer, item_type: string, item_id: integer, event: string, whodunnit: string, object: text, created_at: datetime)
The object have a information are
---
id: 431
heading: some text
body: "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">\n<html><body>\ndfklsjdalfjlds</body></html>\n"
element_type_id: 5
parent_id: 430
position: 1
version_id:
created_at: 2016-04-18 04:35:52.916000000 Z
updated_at: 2016-05-13 04:56:51.371376000 Z
ended_at:
lock_version: 85
display_heading: false
lock_time: 2016-05-13 04:56:51.000000000 Z
locked_by: 16
project_id:
survey_id:
cover_image_id:
details: "{}"
work_id:
ElementVersion.where_object(parent_id: 430)
It is returning an array of records, but I am not able to access "body" content from the above query. Do you have any ideas about how to fix this issue?
ElementVersion.where_object(parent_id: 430) It is returning an array of records, but I am not able to access "body" ..
The Version.where_object
method returns a Relation
of Version
objects, just like the normal where
method.
The Basic Usage section of the documentation describes how to retrieve the original record from a Version
record.
widget = Widget.find 153
widget.name # 'Doobly'
widget.update_attributes :name => 'Wotsit'
widget.versions.last.reify.name # 'Doobly'
So, you can reify
your ElementVersion
record to get, presumably, an Element
, and then call #body
on it.