collection_check_boxes get value

Posted by 24sharon on Stack Overflow See other posts from Stack Overflow or by 24sharon
Published on 2013-10-19T21:50:09Z Indexed on 2013/10/19 21:53 UTC
Read the original article Hit count: 247

Filed under:
|
|

this is my view code

<%=collection_check_boxes(nil, :admin_ids, Admin.all, :id, :name )%>

but when i try get the value in the controller i get always an empty value if the user doesnt check any item and the length is always more than zero

when i write this code

arr =  params[:admin_ids] ||= []
    puts arr.length

ther arr.length is 1 even if the user doesnt select any of the items

how can i get an array of selected items only with no empty values

© Stack Overflow or respective owner

Related posts about arrays

Related posts about checkbox