Skip to content

Instantly share code, notes, and snippets.

@sushant12
Created June 2, 2017 09:09
Show Gist options
  • Save sushant12/a2f4ef1d26e9927b355688e39bba6adb to your computer and use it in GitHub Desktop.
Save sushant12/a2f4ef1d26e9927b355688e39bba6adb to your computer and use it in GitHub Desktop.
saving to db
elsif(env[‘PATH_INFO’] == ‘/save_task’ && env[‘REQUEST_METHOD’] == “POST”)
req = Rack::Request.new(env)
task_name = req.params[“task”]
DB.execute(“INSERT INTO tasks (name, finished) VALUES (?, ?)”, [task_name,0])
return [ 302, {‘Location’ =>”/”}, [] ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment