Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 26th, 2012  |  syntax: None  |  size: 0.33 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Use helper select or select_tag with JSON on Rails 3.2.1
  2. [{"id":"197630", "name":"JOHN PERS"} , {"id":"6", "name":"JOSHUA JOSH"}]
  3.        
  4. @parsed_json = ActiveSupport::JSON.decode(@listJson)
  5.        
  6. <% collection = options_for_select(ActiveSupport::JSON.decode(@list_json).map { |b| [b["name"], b["id"]] }) %>
  7. <%= f.select :name, collection %>