Hie, i am using carmen gem for country and state listing.
my view code is,
<div class=" control-group">
<%= f.label :country, :class => 'control-label' %>
<div class="controls">
<%= f.select :country, Carmen::Country.all.collect{|c| c.name}, {:selected => country}, :remote=>true %>
</div>
</div>
<div class=" control-group">
<%= f.label :state, :class => 'control-label' %>
<div id="addressStates">
<%= render :partial => 'experienceones/states', :locals => {:states => Carmen::Country.named('India').subregions.collect{|sub| sub.name }, :form => f} %>
</div>
</div>
partial state is,
<div class="controls">
<%= fields_for 'experienceones' do |addr_form| %>
<% if !@states.blank? %>
<%= addr_form.select :state, @states, {:prompt => 'Select State'}, {:style => 'width: 180px'} %>
<% else %>
<%= addr_form.text_field :state %>
<% end %>
<% end %>
</div>
jquery is,
jQuery('select#experienceone_country').change(function() {
var country = 'country=' + $('select#experienceone_country :selected').text();
jQuery.ajax({
url: '/experienceones/update_state_select',
data: country,
dataType: 'html',
success: function(data){
jQuery("div#addressStates").html(data);
},
});
});
and in controller i have,
def update_state_select
@states = Carmen::Country.named(params[:country]).subregions.collect{|sub| sub.name } || []
end
when i select country, i am able to get list of state successfully in select tag.
but i get error as,
No route matches [GET] "/experienceones/1/true"
i knw, true is result of my request
GET "/experienceones/update_state_select?country=######"
bt how can i avoid this?
my url for edit is
http://localhost:3000/experienceones/1/edit
if i use,
window.location.href = "/experienceones/<%= @experience.id %>/edit"
in ajax success, i get new edit page.
i want to redirect in same page (i.e edit page) bt with selected country and state.
How can i do this?
Same issue is for new.
Thank You.