Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
Disable multi form submit and constrin the database to only unique se…
Browse files Browse the repository at this point in the history
…rver seeds.
  • Loading branch information
9876691 committed Dec 17, 2014
1 parent 6b5a16d commit f7e0ac4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
8 changes: 8 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ var initialise = function() {

$.material.init();

$('form.submit-once').submit(function(e){
if( $(this).hasClass('form-submitted') ){
e.preventDefault();
return;
}
$(this).addClass('form-submitted');
});

var pusher = new Pusher('1fdb3cf163217908dd6f');
var channel = pusher.subscribe('test_channel');
channel.bind('my_event', function(data) {
Expand Down
2 changes: 1 addition & 1 deletion app/views/visitors/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
%dd
%input#client-seed.form-control{:type => "text"}/
.col-md-6.well
= form_for(@bet, html: { role: 'form', class: 'inline-form', id: 'betForm' }) do |f|
= form_for(@bet, html: { role: 'form', class: 'inline-form submit-once', id: 'betForm' }) do |f|
.row
.col-md-12
%label Probability of winning
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddUniqueConstraintToServerSeed < ActiveRecord::Migration
def change
add_index(:bets, :server_seed, :unique => true)
end
end
4 changes: 3 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20141119122639) do
ActiveRecord::Schema.define(version: 20141217121140) do

create_table "balances", force: true do |t|
t.string "transaction_hash"
Expand All @@ -34,6 +34,8 @@
t.datetime "updated_at"
end

add_index "bets", ["server_seed"], name: "index_bets_on_server_seed", unique: true

create_table "cashouts", force: true do |t|
t.string "address"
t.integer "amount"
Expand Down

0 comments on commit f7e0ac4

Please sign in to comment.