Reinstalling a Rails app on a new server.  Part of the app can fork in one of two directions based on the button the user selects.  This part isn't working, and when I look at the log I see the values that I gave the form, execept for the commit portion of the params hash.  This seems to be why the app isn't working as expected (since there's nothing in params[:commit], but I have no idea why commit would not be passed in; the request is definitely a POST request, and all of the other parameters are there.
Just add name: "commit", value: "Save"to your form submit button:
form_for @object do |f|
  ...
  f.button :submit, "Save", name: "commit", value:"Save"
end
and then you will have params[:commit] equals to "Save" in the controller.
Had a simular problem with a disable-button-on-submit feature. We solved it by adding a hidden input field with the same name and value before submitting the form.
function disableButtonAndSubmit()
{
  var input = $("<input type='hidden' />").attr("name", $(this)[0].name).attr("value", $(this)[0].value);
  $(this).closest('form').append(input);
  $(this).attr('disabled', 'disabled').html('Loading…');
  $(this).closest('form').submit();
}
$('#somewhere button').click(disableButtonAndSubmit);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With