forked from openshift/ruby-hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openshift#19 from bparees/add_crud
update sample app to do crud ops
- Loading branch information
Showing
5 changed files
with
109 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class CreateKeyPair < ActiveRecord::Migration | ||
def up | ||
create_table :key_pairs, :primary_key => :key do |t| | ||
t.string :value | ||
end | ||
change_column :key_pairs, :key, :string | ||
end | ||
|
||
def down | ||
drop_table :keypairs | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<html> | ||
<head> | ||
<title>Hello from OpenShift v3!</title> | ||
</head> | ||
<body> | ||
Welcome to an OpenShift v3 Demo App! | ||
|
||
|
||
<form name="myForm" onSubmit="return handleSubmit()"> | ||
Key: | ||
<input type="text" id="key" name="Key"/> | ||
<input type="submit" id="get" name="action" value="Get"/> | ||
<input type="submit" id="put" name="action"value="Put"/> | ||
<input type="submit" id="delete" name="action" value="Delete"/> | ||
</form> | ||
Value: | ||
<input type="text" id="value" name="value" value=""> | ||
</body> | ||
|
||
<script type="text/javascript"> | ||
function handleSubmit() | ||
{ | ||
|
||
|
||
//document.getElementById("value").value="updated"; | ||
return false; | ||
} | ||
|
||
document.getElementById('get').onclick = function() { | ||
xmlHttp = new XMLHttpRequest(); | ||
xmlHttp.open( "GET", "http://"+window.location.hostname+":"+window.location.port+"/keys/"+document.getElementById("key").value, false ); | ||
xmlHttp.send( null ); | ||
document.getElementById("value").value=xmlHttp.responseText; | ||
} | ||
|
||
document.getElementById('put').onclick = function() { | ||
xmlHttp = new XMLHttpRequest(); | ||
xmlHttp.open( "POST", "http://"+window.location.hostname+":"+window.location.port+"/keys/"+document.getElementById("key").value, false ); | ||
var params = "value="+document.getElementById("value").value; | ||
|
||
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); | ||
xmlHttp.setRequestHeader("Content-length", params.length); | ||
xmlHttp.setRequestHeader("Connection", "close"); | ||
|
||
xmlHttp.send( params ); | ||
document.getElementById("value").value=xmlHttp.responseText; | ||
} | ||
|
||
document.getElementById('delete').onclick = function() { | ||
xmlHttp = new XMLHttpRequest(); | ||
xmlHttp.open( "DELETE", "http://"+window.location.hostname+":"+window.location.port+"/keys/"+document.getElementById("key").value, false ); | ||
xmlHttp.send( null ); | ||
document.getElementById("value").value="Key deleted"; | ||
} | ||
|
||
</script> | ||
|
||
</html> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
require 'active_record' | ||
|
||
class Timestamp < ActiveRecord::Base | ||
class KeyPair < ActiveRecord::Base | ||
self.primary_key='key' | ||
end |