Good community. I present a problem in Rails with a route that I specify by means of AJAX which gives me an error of 400 Bad Request .
This is my way:
ruta archivo:app/views/admin/orders/_form.html.haml
.wrapper
.wrapper-body.container
.actions
= link_to admin_orders_path, class: "btn-floating btn-flat tooltipped", "data-position" => "bottom", "data-tooltip" => t("keppler.actions.back") do
= material_icon.md_18.arrow_back.css_class("md-dark")
.wrapper-inputs
.card
.card-content
= simple_form_for [:admin, @order] do |f|
.row
= f.input :name_pro, collection: @projects, label_method: :name, value_method: :id, label: "Seleccionar Proyecto", include_blank: true
#activities
-# = f.input :name_pro
-# = f.input :item_pro
.form-actions.right
= f.button :submit, t("keppler.actions.save"), name: '_save'
= f.button :submit, t("keppler.actions.save_and_add_another"), name: '_add_other'
:javascript
$(document).ready(function() {
$('#order_name_pro').on('change', function() {
$.ajax({
url: "<%= items_options_path %>",
type: "POST",
data: { project_id: $(this).val() }
});
});
});
And I leave the link of the code complete.