---
- !ruby/object:Comment
attributes:
post_id: '5'
changed_attributes: {}
previously_changed: {}
attributes_cache: {}
marked_for_destruction: false
destroyed: false
readonly: false
new_record: false
- !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)
如何将post_id
的值作为数组?
@arr = [ 5,6,3,7,1 ]
现在我想用post_id
获取这些帖子。
它是否正确 ?
@p = Post.where(:id=>@arr)
答案 0 :(得分:0)
@p = Post.find(my_collection.map(&:post_id))