I have a JSON array that was returned from Foursquare; let\'s call it @venues
. I want to be able to \"select\" a venue via a drop down box and I want it to be p
Controller
@venues = JSON.parse @venues
View
<%= select(:model, :venue_id, @venues.map {|v| [ v['venue']['name'], v['venue']['id'] ] }) %>
Or to be more cleaner:
Controller
@venues = JSON.parse @venues
@venues_list = @venues.map { |v| v['venue'] }
View
<%= select(:model, :venue_id, @venues_list.map {|v| [ v['name'], v['id'] ] }) %>
More information about select helper.