在 PaperTrail gem 中,无法访问对象的数据
In PaperTrail gem, an object's data isn't accessible
我在应用程序中使用 paper_trail (https://github.com/airblade/paper_trail) gem 进行商店版本控制。我用 class_name 自定义。我可以通过查询收集记录,但如何访问对象的数据
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)
它正在返回一组记录,但我无法从上述查询访问“正文”内容。您对如何解决此问题有任何想法吗?
ElementVersion.where_object(parent_id: 430)
It is returning an array of records, but I am not able to access "body" ..
Version.where_object
方法 returns Relation
个 Version
对象,就像普通的 where
方法一样。
文档的 Basic Usage 部分描述了如何从 Version
记录中检索原始记录。
widget = Widget.find 153
widget.name # 'Doobly'
widget.update_attributes :name => 'Wotsit'
widget.versions.last.reify.name # 'Doobly'
因此,您可以 reify
您的 ElementVersion
记录来获取大概 Element
,然后对其调用 #body
。
我在应用程序中使用 paper_trail (https://github.com/airblade/paper_trail) gem 进行商店版本控制。我用 class_name 自定义。我可以通过查询收集记录,但如何访问对象的数据
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)
它正在返回一组记录,但我无法从上述查询访问“正文”内容。您对如何解决此问题有任何想法吗?
ElementVersion.where_object(parent_id: 430) It is returning an array of records, but I am not able to access "body" ..
Version.where_object
方法 returns Relation
个 Version
对象,就像普通的 where
方法一样。
文档的 Basic Usage 部分描述了如何从 Version
记录中检索原始记录。
widget = Widget.find 153
widget.name # 'Doobly'
widget.update_attributes :name => 'Wotsit'
widget.versions.last.reify.name # 'Doobly'
因此,您可以 reify
您的 ElementVersion
记录来获取大概 Element
,然后对其调用 #body
。