From d17ab054cfa0d44fa36a20b249b2cab7ef99e9d4 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Mon, 27 Jun 2016 14:08:57 +0100 Subject: Correctly returns todo ID after creating todo --- app/services/todo_service.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/services/todo_service.rb b/app/services/todo_service.rb index 540bf54b920..239bd17a035 100644 --- a/app/services/todo_service.rb +++ b/app/services/todo_service.rb @@ -159,8 +159,9 @@ class TodoService def create_todos(users, attributes) Array(users).map do |user| next if pending_todos(user, attributes).exists? - Todo.create(attributes.merge(user_id: user.id)) + todo = Todo.create(attributes.merge(user_id: user.id)) user.update_todos_count_cache + todo end end -- cgit v1.2.1