I'm using a form_tag
to update an attribute in my 'Car' model. Everything should work except when I check the logs its using GET instead of the PUT like it should.
apply_superadmin_apply_coupons_path - PUT /superadmin/apply_coupons/apply(.:format) superadmin/apply_coupons#apply
superadmin_apply_coupons_path - GET /superadmin/apply_coupons(.:format) superadmin/apply_coupons#index
<form class="super-admin-apply-coupons form-horizontal">
<%= form_tag(apply_superadmin_apply_coupons_path, action: 'apply', method: 'PUT') do %>
<div class="form-group">
<label class="col-sm-2"> Select car</label>
<div class="col-sm-4 apply-coupon-wrap">
<%= select_tag :id, options_from_collection_for_select(@cars, "id", "device_number"), class:"form-control" %>
</div>
</div>
<div class="form-group">
<label class="col-md-2">Select coupon code</label>
<div class="col-sm-4 apply-coupon-wrap">
<%= select_tag :coupon_code_id, options_from_collection_for_select(@coupon_codes, "id", "name"), class:"form-control" %>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-4">
<%= submit_tag 'Apply', class: 'btn btn-success' %>
</div>
</div>
<% end %>
</form>
Its obviously just redirecting back to the index page at the moment without triggering the apply action I'm wanting it to.
You are probably producing two <form>
tag in your view, one is the html form tag, the other is from <%=form_tag(...)%>
. Just try to remove the html form tag might make it.