开发者

How can i extract value from object?

---
- !ruby/object:Comment
  attributes:
    post_id: '5'
  changed_attributes: {}
  previously_changed: {}
  attributes_cache: {}
  marked_for_destruction: false
  destroyed: false
  readonly: false
  new_record: false开发者_Go百科
- !ruby/object:Comment
  attributes:
    post_id: '6'
  changed_attributes: {}
  previously_changed: {}
  attributes_cache: {}
  marked_for_destruction: false
  destroyed: false
  readonly: false
  new_record: false
- !ruby/object:Comment
  attributes:
    post_id: '3'
  changed_attributes: {}
  previously_changed: {}
  attributes_cache: {}
  marked_for_destruction: false
  destroyed: false
  readonly: false
  new_record: false
- !ruby/object:Comment
  attributes:
    post_id: '7'
  changed_attributes: {}
  previously_changed: {}
  attributes_cache: {}
  marked_for_destruction: false
  destroyed: false
  readonly: false
  new_record: false
- !ruby/object:Comment
  attributes:
    post_id: '1'
  changed_attributes: {}
  previously_changed: {}
  attributes_cache: {}
  marked_for_destruction: false
  destroyed: false
  readonly: false
  new_record: false

(http://pastebin.com/J1angM6d)

How can i get the value of post_id as array? @arr = [ 5,6,3,7,1 ] Now i want to get those posts with this post_id. Is this correct ? @p = Post.where(:id=>@arr)


@p = Post.find(my_collection.map(&:post_id))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜