2012-07-10 4 views
0

나는 Mailboxer 보석을 사용하고 있습니다.한 번에 여러 레코드의 플래그를 전환하려면 어떻게해야합니까?

행이 확인되고 뷰가 복수 ID를 전달하지만이 작업은 매개 변수를받을 때 첫 번째 ID #의 레코드 만 삭제합니다.

매개 변수에 전달 된 ID에 해당하는 모든 레코드를 휴지통으로 처리하려면 어떻게해야합니까?

매개 변수

{"utf8"=>"✓", 
"authenticity_token"=>"35UoVt+dvwrGAgg+KZjn8jCZjlkdPj1ktCg5ASyCI4w=", 
"checked_items"=>{"15"=>"15", 
"14"=>"14"}, 
"commit"=>"Trash All Checked"} 

액션

대신 find_by_id 사용 find_all_by_id의
def discard 

    conversation = Conversation.find_by_id(params[:checked_items].keys) 

    if conversation 

    current_user.trash(conversation) 

    flash[:notice] = "Message sent to trash." 

    else 

    conversations = Conversation.find(params[:conversations]) 

    conversations.each { |c| current_user.trash(c) } 

    flash[:notice] = "Messages sent to trash." 

    end 

    redirect_to :back 

end 
+2

find_by_id 대신 find_all_by_id를 사용하면 모든 대화가 하나씩 차례로 처리됩니다. – Arun

+0

감사! 그것은 완전히 작동합니다! – MKK

답변

0

하고 다음 하나씩 쓰레기 모든 대화를 얻을 것이다.

관련 문제