Я хотел бы спросить совета в моей маленькой проблеме.Это мой класс , это мой контроллер .Я хочу сделать это приложение многопоточным. Скажите, пожалуйста, какой путь будет лучше? Быстрый взлом контроллера не решает проблему:
if params[:select].present?
threads = []
params[:select].each do |item|
threads << Thread.new {
tweet = current_user.tweet.detect {
|t| item == t.name
}
config = {
.....
etc
}
end
threads.each(&:join)
Не работает, процесс сразу останавливается:
Started GET "/tweets?select%5B%5D=adamasmit&select_action=follow&tag=&tag1=" for 127.0.0.1 at 2019-03-06 01:37:28 +0300
Processing by TweetsController#index as */*
Parameters: {"select"=>["adamasmit"], "select_action"=>"follow", "tag"=>"", "tag1"=>""}
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ? [["id", 11], ["LIMIT", 1]]
Tweet Load (0.6ms) SELECT "tweets".* FROM "tweets" WHERE "tweets"."user_id" = ? [["user_id", 11]]
и это все.
Это пример нормальной работы приложения:
Started GET "/tweets?select=adamasmit&select_action=unfollow&tag=&tag1=" for 127.0.0.1 at 2019-03-06 18:17:43 +0300
Processing by TweetsController#index as */*
Parameters: {"select"=>"adamasmit", "select_action"=>"unfollow", "tag"=>"", "tag1"=>""}
User Load (1.8ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ? [["id", 11], ["LIMIT", 1]]
Tweet Load (0.3ms) SELECT "tweets".* FROM "tweets" WHERE "tweets"."user_id" = ? [["user_id", 11]]
adding follower to an array: cmirnow
adding follower to an array: travel_slovenia
adding follower to an array: godraksha
.....
etc
adding follower to an array: Pkakooza
adding follower to an array: chrissycrew3
adding friend to an array: cmirnow
adding friend to an array: travel_slovenia
adding friend to an array: godraksha
.....
etc
adding friend to an array: Pkakooza
adding friend to an array: chrissycrew3
adding friend to an array: RivaresF
follow: RivaresF
Rendering tweets/index.html.erb within layouts/application
Rendered tweets/index.html.erb within layouts/application (3.7ms)
Completed 200 OK in 3311ms (Views: 132.1ms | ActiveRecord: 2.6ms)
(0.1ms) begin transaction
(0.1ms) commit transaction
Что вы посоветуете?