开发者

How can i extract value from object?

开发者 https://www.devze.com 2023-03-21 00:51 出处:网络
--- - !ruby/object:Comment attributes: post_id: \'5\' changed_attributes: {} previously_changed: {} attributes_cache: {}
---
- !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

精彩评论

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