Skip to content

Instantly share code, notes, and snippets.

@sushant12
Last active June 4, 2017 11:27
Show Gist options
  • Save sushant12/f88d90993e502f645b0cf0f92eeb0340 to your computer and use it in GitHub Desktop.
Save sushant12/f88d90993e502f645b0cf0f92eeb0340 to your computer and use it in GitHub Desktop.
require 'active_record'
require 'pg'
require 'sinatra'
ActiveRecord::Base.establish_connection(
adapter: 'postgresql',
host: 'localhost',
username: 'postgres',
password: 'postgres',
database: 'testdb'
)
class Task < ActiveRecord::Base
validates :name, presence: true
end
get '/' do
@tasks = Task.all
erb :index
# erb :index, locals: {tasks: Task.all}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment