I want to display my houses with a checkbox next to each of them, how do
i do it?
I know i could do check_box(“house[]”,“enabled”) if my houses could be
enabled. But what do you do if you just want a list of the ids of the
selected houses?
Any ideas? I’m sooo sure this is stupidly easy. I feel stupid.
I’ve had to do this and it doesnt seem right, although it works:
[view]
<% for @house in @houses %>
<%=check_box “house[]”,“nil?” %>
<% end
[controller]
#this method will return a list of selected house ids:
def get_selected_houses
ids=[]
params[param].each_pair do |key,value|
if value[“nil?”]==“1”
ids << key
end
end
false
end
Any ideas what the rails way of doing this is?
Thanks
Chris