assemblymade/coderwall — pull request #259 by codebender (2014-12-11 06:31:39+00:00)
Title: disable registration submit button after 1 click

[Bounty 446 - BUG: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_users_on_username" DETAIL: Key (username)=(XXXXXXX) already exists.](https://assembly.com/coderwall/bounties/446)
---

I have seen this sort of problem in the past on other projects. Adding ```data: { disable_with: "Submitted" }``` to a submit_tag or link_to disables the button after the first click. I smoke tested locally and it works as advertised. For more info: http://www.railsonmaui.com/blog/2014/02/23/simple-form-and-disable-processing-by-default/

BTW, our ```validates_uniqueness_of :username``` does work, but double clicks create a race condition. :racehorse: :car::dash: