2011-07-17 8 views
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)

+0

に-1 – corroded

+0

しかしこれが正しいかどうかを尋ねる必要はありませんが、あなたは、単にそれを試みることによって自分自身に答えることができる質問です。あなたは私たちに教えてください、それは動作しますか?それはあなたがしたいことをしていますか?あなたがそれを試してもうまくいかなかった場合、あなたは人を打つためにはるかに良い質問があります。 Thiloも言っているように、あなたの質問に誰かが返信する前に、回答を受け入れる必要があります。 –

+0

@corroded私ではない:) – Thilo

答えて

0
@p = Post.find(my_collection.map(&:post_id)) 
関連する問題