0
---
- !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)
无需-1虽然 – corroded
问,如果这是正确的,你可以通过简单地尝试它自己回答的问题。你告诉我们,它工作吗?它做你想做的事吗?如果你尝试过它并没有奏效,那么你有更好的问题来打击人们。正如Thilo所说,你需要在任何人回答你的问题之前开始接受答案 –
@corroded不是我:) – Thilo