Skip to main content
Ask A Question
Notifications
You’re not receiving notifications from this thread.
Subscribe

How Do i add an "Are You Sure?" button in my update controller

Rails • Asked by Neil Patel

Hi

I want add a pop up button that says "Are you sure" when the user clicks on submit ? if it was a destroy mehod it would be something like this method: :delete, data: { confirm: "Are you sure?"} but not sure how to do it on the update method

def update
    if donation_plan.update(donation_plan_params)
      redirect_to :back, notice: "Thank you for your Gift Aid Donation"
    else
      render :show
    end
  end

or do i add this to the show page

 = simple_form_for donation_plan, url: my_donations_path do |f|
                  = f.input :giftaid, inline_label: " reclaim Gift Aid of 25p, in every £1 on past donations and all future donations I may make.", label: false
                  %p= f.submit "Submit", class: "btn btn-primary"

I think its this
%p= f.submit "Submit", class: "btn btn-primary", data: { confirm: "Are you Sure"}


Yeah, data-confirm is just a generic attribute you can use on any clickable item, not just delete links. That should work fine.



Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 30,005+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.