【发布时间】:2013-08-04 04:10:25
【问题描述】:
我想从 2 个设备获取 2 个 url 图片。我的模型结构:
比较:has_one :device1, has_one :device2
设备:has_one :image
图片: mount_uploader :image, 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
【问题讨论】:
标签: ruby json ruby-on-rails-3 mongoid