Closed Siggs2000 closed 9 years ago
You should try this:
options: Hash[AreaPlace.map do |place|
[place.id, place.name]
end]
What it will do is the following
places = AreaPlace.map do |place|
[place.id, place.name]
end
=> [["id_1", "Name1"], ["id_2", "Name2"], ["id_3", "Name3"]]
Hash[places]
=> {"id_1"=>"Name1", "id_2"=>"Name2", "id_3"=>"Name3"}
:+1:
I'm sure there's a way to do this but I can't seem to figure it out...
I have a model with certain city/state names like this: "Dallas, TX", "San Diego, CA", etc
And in a form selector (any type of selector will do) I'm trying something like this:
But I get this syntax error: