Last active
January 20, 2016 15:18
-
-
Save moyashiki/0d55f84396c0299ef5e9 to your computer and use it in GitHub Desktop.
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
require 'active_record' | |
ActiveRecord::Base.configurations = YAML.load_file('./database.yml') | |
ActiveRecord::Base.establish_connection(:development) | |
class User << ActiveRecord::Base | |
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
development: | |
adapter: "sqlite" | |
database: "dev.db" |
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
require './database.rb' | |
ActiveRecord::Migration.drop_table :users | |
ActiveRecord::Migration.create_table :users do |t| | |
t.string :username | |
t.integer :age | |
t.datetime :birthday | |
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
require 'sinatra' | |
require 'sinatra/reloader' | |
require './database.rb' | |
set :bind, '0.0.0.0' | |
get '/' do | |
users = User.all | |
slim :index | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment