我想从 2 个设备中获取 2 个 url 图像。我的模型结构:
比较: has_one :device1, has_one :device2
设备: has_one :image
图片:mount_uploader:图片,ImageUploader
在查询中,我想从查询中获取 JSON 数组比较
@compares = Compare.any_of({:device1_id.in => arr_device_id},{:device2_id.in => arr_device_id})
我试试:(标题是 attr_accessor)
Compare.any_of({:device1_id.in => arr_device_id},{:device2_id.in => arr_device_id}).only(:title => 'abc'). Result json is not contain field title
@compare.to_json(:include => [:device1,:device2]) => this include device1 and device2 but not include image of it.
@compare.to_json(:method => [:title => 'abc']) . Result json is not contain field title
有什么解决办法吗?感谢您的帮助:D