hi all,
i am new to rails and not able to figure how to get a drop-down
selection list in a view.
i have 3 models (tables): country, state & city.
country has many states
state has many cities
now i want to create 3 drop down lists, 1 for each. selecting a
country should make states available in that country only, and same
for the state and cities.
i am trying to create the ‘country’ list with this:
<%= collection_select(:state, :countries_id,
@countries, :id, :cou_name, {:prompt => “select country”}) %>
def select
@countries = Country.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @countries }
end
end
although the box is shown, but nothing comes up in it.
i am trying to do this inside a view for ‘state’. do i need to do it
inside a separate controller/view??
plz help!!