0
ルーティングエラーが発生するルートがありません[POST] "/ update_cities"以下は自分のコードです。私は正確な値がURLのajaxリクエストで与えられるべきであることを知ることができません。私を助けてください、私はレールに新しいです。ruby on railsでajaxリクエストでコントローラ名をurlとして与える方法は?
**Ajax request**
$(document).ready(function(){
$('#state_select').on('change', function(){
$.ajax({
url: "/update_cities",
type: "POST",
data: {state_id: $(this).val()}
})
.done(function(data) {
$.each(data, function (i, item) {
$('#city_select').append($('<option>', {
value: item.value,
text : item.text
}));
});
});
}); });
**Route**
post 'colleges/update_cities' => 'colleges#update_cities'
**Action in colleges_controller file**
def update_cities
@cities = City.where("state_id = ?", params[:state_id])
respond_to do |format|
format.js
end
end
「url:/ colleges/update_cities」「 – Pavan
Thanks Pavan」に変更してみてください。それは働いている。 :) – scripter