I don't know how to return checked values. There is my code
controller:
def index
// there I would like to get checked cities
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @cities }
end
end
viewer:
<%= render 'form' %>
_form:
<% for cities in Database.find(:all) %>
<div>
<%= check_box_tag cities.city1 %>
<%= cities.city1 %>
</div>
<% end %>
EDIT
I tried:
@cities = Database.find(:all)
params[:cities].each do |city|
...
end
and
<% for city in @cities %>
<%= check_box_tag "cities[]", city.id %> <%= city.city1 %>
<% end %>
but got error:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each