Last active
December 23, 2016 05:36
Revisions
-
mopsled revised this gist
Feb 20, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -29,10 +29,10 @@ selectedColor.name = params['name'] end if params.has_key?('description') selectedColor.description = params['description'] end if params.has_key?('value') selectedColor.value = params['value'] end selectedColor.save end -
mopsled revised this gist
Feb 23, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ require 'sinatra' require 'active_record' require "./color.rb" -
mopsled revised this gist
Jan 9, 2013 . 2 changed files with 5 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,6 +6,6 @@ create_table :colors do |t| t.column :name, :string t.column :description, :string t.column :value, :string 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 charactersOriginal file line number Diff line number Diff line change @@ -14,10 +14,10 @@ end post '/color' do if params.has_key?('name') and params.has_key?('description') and params.has_key?('value') newColor = Color.new(:name => params['name'], :description => params['description'], :value => params['value']) newColor.save end end @@ -31,8 +31,8 @@ if params.has_key?('description') selectedColor.name = params['description'] end if params.has_key?('value') selectedColor.name = params['value'] end selectedColor.save end -
mopsled revised this gist
Jan 9, 2013 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ require "sinatra" require 'active_record' require "./color.rb" ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => 'colors.db') -
mopsled revised this gist
Jan 9, 2013 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,7 @@ require 'active_record' ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => 'colors.db') ActiveRecord::Schema.define do create_table :colors do |t| t.column :name, :string -
mopsled created this gist
Jan 6, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ require 'active_record' class Color < ActiveRecord::Base 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ ActiveRecord::Schema.define do create_table :colors do |t| t.column :name, :string t.column :description, :string t.column :color, :string 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ require "sinatra" require "./color.rb" ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => 'colors.db') ActiveRecord::Base.include_root_in_json = false get '/colors' do Color.all.to_json end get '/color/:id' do Color.where(:id => params['id']).first.to_json end post '/color' do if params.has_key?('name') and params.has_key?('description') and params.has_key?('color') newColor = Color.new(:name => params['name'], :description => params['description'], :color => params['color']) newColor.save end end put '/color/:id' do selectedColor = Color.where(:id => params['id']).first if selectedColor if params.has_key?('name') selectedColor.name = params['name'] end if params.has_key?('description') selectedColor.name = params['description'] end if params.has_key?('color') selectedColor.name = params['color'] end selectedColor.save end end delete '/color/:id' do Color.where(:id => params['id']).destroy_all end