ruby on rails - How do I create a dropdown list specifically for Indian states and cities? -
my app planned go india , need add location information user profiles. there way create dropdowns myself states , cities or gems india.
i mean if feed states , cities myself want showing user , allow him choose his, how do that?
i can't work text fields because want make whole thing searchable locations , if users enter different locations quality of search drastically decrease.
links tutorials welcome :)
you use form select
helper. if have possible states in activerecord, can in form:
<%= f.select :state_id, state.all.collect {|s| [s.name, s.id]} %>
if don't want them in activerecord, define array of in model, , feed form.
also, take @ enumerize, gem, it's useful if have finite set of options field.
and thing, there countries , cities gems householding city/country data.
Comments
Post a Comment