Tag: Ruby On Rails

Group operations in a transaction

ActiveRecord wraps the creation or update of a record in a single transaction. Multiple inserts will then generate many transactions (one for each insert). Grouping multiple inserts in one single transaction will speed things up. Insead of: my_collection.each do |q| Report.create({:phrase => q}) end Use: Report.transaction do my_collection.each do |q| Report.create({:phrase => q}) end end …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/11/group-operations-in-a-transaction/

Refresh / Redirection

When you need your web page automatic refresh in 5 second or any second, use this meta tag.  It’s a simple code, put it between HEAD tag in your web page. This script easy but powerful. <HEAD> <meta http-equiv=’refresh’ content=’2;url=’file_name or URL’> </HEAD> // content = time (second) // file_name = name of file you …

Continue reading

Permanent link to this article: https://blog.openshell.in/2010/11/refresh-redirection/