Rails 3 ActiveRecord Temporary Tables

How to do the following in Rails 3?

CREATE TEMPORARY TABLE average_user_total_time (SELECT SUM(time) AS time_taken FROM scores WHERE created_at >= '2010-10-10' and created_at <= '2010-11-11' GROUP BY user_id); SELECT COUNT(*) from average_user_total_time WHERE time_taken > 60 and time_taken < 600 

I tried to do something like

 create_table (:average_user_total_time), :temporary=> true do |t| end 

but not sure how to use it. I need to use it in my application, not in migration.

+4
source share
1 answer
+6
source

Source: https://habr.com/ru/post/1345018/


All Articles