dimanche 1 novembre 2015

How to select state based on country selection in rails?

I have 2 tables in DB, Countries and States. Now, When I select Countries based on selection it must show the states.

for Country selection in .rhtml file i am using as below:

<%= select_tag "User[country_id]", options_for_select(Country.all.collect{|x| [x.country,x.id]})%>

now based on above selection i need to select the states.

Aucun commentaire:

Enregistrer un commentaire