Permalink
Browse files

post działa

  • Loading branch information...
Janusz Bossy Janusz Bossy
Janusz Bossy authored and Janusz Bossy committed Sep 3, 2011
1 parent a87b58e commit d3df8be10a90bc638aed642c646e767526b23374
Showing with 7 additions and 4 deletions.
  1. +7 −4 twitter/app/actions/Update.rb
@@ -8,15 +8,18 @@ def start
createdAt = Time.now.to_s
DB.new.db_for_user(name) do |db, id, pool, fiber|
- query = db.aquery("INSERT INTO statuses (text, created_at, user_id) VALUES ('#{status}', '#{createdAt}', #{id}); SELECT LAST_INSERT_ID();")
+ query = db.aquery("INSERT INTO statuses (text, created_at, user_id) VALUES ('#{status}', '#{createdAt}', #{id});")
query.errback do |r|
p r
finish
end
query.callback do |r|
- p r
- pool.release(fiber)
- finish
+ db.aquery("SELECT LAST_INSERT_ID() AS x").callback do |idc|
+ p idc
+ render %{{"created_at":"#{createdAt}","id":#{idc.each.to_a[0]['x']}}}
+ pool.release(fiber)
+ finish
+ end
end
end

0 comments on commit d3df8be

Please sign in to comment.