This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form method="POST" action="/our/url"> | |
<!-- this should have the current value of version_number --> | |
<input type="hidden" name="version_number" value="1" /> | |
<textarea name="input" onChange="save(event)" /> | |
</form> | |
function save(event) { | |
event.target.form['version_number'].value++; | |
var request = new XMLHttpRequest(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RecordsController < ApplicationController | |
def update | |
# TODO: remove the line below when the testing is complete | |
sleep(1) if 0 == params[:input].length % 2 | |
@record = Record.find(params[:id]) | |
@record.update(field_name: params[:input]) if params[:version_number] > @record.version_number | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RecordsController < ApplicationController | |
def update | |
# TODO: remove the line below when the testing is complete | |
sleep(1) if 0 == params[:input].length % 2 | |
@record = Record.find(params[:id]) | |
@record.update(field_name: params[:input]) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form method="POST" action="/our/url"> | |
<textarea name="input" onChange="save(event)" /> | |
</form> | |
<script language="javascript"> | |
function save(event) { | |
var request = new XMLHttpRequest(); | |
request.open(event.target.form.method, event.target.form.action); | |
request.send(new FormData(event.target.form)); | |
} |