collection_select issues with rails

8 views
Skip to first unread message

amvis

unread,
Apr 19, 2012, 2:13:34 PM4/19/12
to rubyonra...@googlegroups.com
     data = ActiveSupport::JSON.decode(response.body)
      @catg = data["cat"]


i have to populate the dropdown with id and name from  @catg, when i display this @catg i got like this

[{"created_at"=>"2012-03-31T05:50:27Z", "id"=>1, "name"=>"None", "updated_at"=>"2012-03-31T05:50:27Z"}]

so how to get this into dropdown, and also i tried like this, actually i didn't understand the first two fields of collection_select, but here just i guess that.

<%= form_for(@biz) do |f| %>

<%= collection_select :post,:categories, @catg, :id, :name %>

<% end %>

Got the error 
undefined method `name' for #<Hash:0xb27db74>


Thank you
vishnu

Reply all
Reply to author
Forward
0 new messages