Created
May 2, 2012 14:05
Revisions
-
DaveEveritt revised this gist
May 2, 2012 . 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 @@ -6,7 +6,7 @@ module Sqltest::Models class User < Base end class CreateTables < V 1.0 def self.up # should this now be self.change ? create_table :sqltest_users, :force => true do |t| t.column :id, :integer, :null => false t.column :name, :string, :limit => 255 -
DaveEveritt revised this gist
May 2, 2012 . 1 changed file with 31 additions and 31 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 @@ -3,53 +3,53 @@ Camping.goes :Sqltest module Sqltest::Models class User < Base end class CreateTables < V 1.0 def self.up create_table :sqltest_users, :force => true do |t| t.column :id, :integer, :null => false t.column :name, :string, :limit => 255 t.column :password, :string, :limit => 255 end def self.down drop_table :sqltest_users end end end end module Sqltest::Controllers class Index < R '/' def get # creates a new user: user = User.new() user.id = "mytest" user.name = "My Test" user.password = "testpass" user.save $sqltest = 'created' # to remove user just created, comment code above, # uncomment code below, reload in browser: # user = User.find("mytest") # user.destroy() # $sqltest = 'removed' render :fin end end end module Sqltest::Views def fin "Camping SQLite test finished, no errors. User: " + $sqltest end end def Sqltest.create Sqltest::Models.create_schema :assume => (Sqltest::Models::User.table_exists? ? 1.0 : 0.0) end # adapted from: -
DaveEveritt created this gist
May 2, 2012 .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,57 @@ require 'camping' Camping.goes :Sqltest module Sqltest::Models class User < Base end class CreateTables < V 1.0 def self.up create_table :sqltest_users, :force => true do |t| t.column :id, :integer, :null => false t.column :name, :string, :limit => 255 t.column :password, :string, :limit => 255 end def self.down drop_table :sqltest_users end end end end module Sqltest::Controllers class Index < R '/' def get # creates a new user: user = User.new() user.id = "mytest" user.name = "My Test" user.password = "testpass" user.save $sqltest = 'created' # to remove user just created, comment code above, # uncomment code below, reload in browser: # user = User.find("mytest") # user.destroy() # $sqltest = 'removed' render :fin end end end module Sqltest::Views def fin "Camping SQLite test finished, no errors. User: " + $sqltest end end def Sqltest.create Sqltest::Models.create_schema :assume => (Sqltest::Models::User.table_exists? ? 1.0 : 0.0) end # adapted from: # http://www.slideshare.net/feyeleanor/camping-going-off-the-rails-with-ruby # slide 40