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