Skip to content

Instantly share code, notes, and snippets.

@jamalmoir
Created July 11, 2015 09:44
Show Gist options
  • Save jamalmoir/50b46fa2fd19bfb566d2 to your computer and use it in GitHub Desktop.
Save jamalmoir/50b46fa2fd19bfb566d2 to your computer and use it in GitHub Desktop.
#app.rb
class User
include DataMapper::Resource
property :id, Serial
property :username, String, :required => true
property :password, String, :required => true
property :created_at, DateTime
property :updated_at, DateTime
end
DataMapper.finalize.auto_upgrade!
class SimpleBlog <Sinatra::Base
enable :sessions
helpers Sinatra::SimpleBlog::Helpers
register Sinatra::SimpleBlog::Routing
end
#routes/routes.rb
module Sinatra
module SimpleBlog
module Routing
app.post '/register' do
#TODO: Validate
User.create(:username => params[:username],
:password => encrypt_sha2(params[:password]),
:created_at => Time.now,
:updated_at => Time.now)
redirect '/login'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment