0

I have a rails form calling upon the create function in my controller, and I've noticed if i press the submit button multiple times while the page loads, I am able to submit the form multiple times. Is there a way to prevent this from happening? My button is:

<%= button_to edit_production_path(id: current_user.default_working_production_id), class: "btn btn-default navbar-btn", :method => :get do %><span class="glyphicon glyphicon-film"></span>&nbsp; Production Settings<% end %>

And my controller is:

def create
    @production = Production.new(production_params)
    @production.user = current_user
    @production.user_name = current_user.name

    if @production.save
        redirect_to productions_path
    else
        render 'new'
    end
end`

1 Answer 1

3

I notice you are using edit_path, which should be a put to the update action, but you are specifying :get as the method. Are you sure this is going to your create action?

In order to prevent double submits you will need to disable with javascript, add this to the button.

data: { disable_with: "Submitting..."}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.