FirstDEV blog
  • Home
  • Ruby
  • Ruby On Rails
  • Tips
  • Solutions
  • About
Subscribe

Rails-code

A collection of 19 posts

Rails-code

Bulk Insert Records With Insert_all And Skip Duplicates In Rails

Importing thousands of rows one create! at a time issues one INSERT per record plus validations and callbacks. insert_all sends a single multi-row INSERT, which is orders of magnitude faster for imports and

Rajan Bhattarai Rajan Bhattarai 2 min read
Rails-code

Prevent Duplicate Form Submissions In Rails With An Idempotency Key

A user double-clicks Submit, or a mobile client retries after a timeout it thought had failed. Two identical requests arrive and you create two orders. Disabling the button in JavaScript does not solve

Rajan Bhattarai Rajan Bhattarai 2 min read
Rails-code

Query Records Created Or Updated In The Last N Hours In Rails

Dashboards, digest emails, and sync jobs all need “what changed recently”. Rails’ duration helpers plus a beginless or endless range make this readable and, crucially, index-friendly.

Rajan Bhattarai Rajan Bhattarai 1 min read
Rails-code

Paginate Activerecord Results Without A Gem Using Limit And Offset

Kaminari and Pagy are excellent, but a JSON API or an internal admin screen often needs nothing more than a page number and a page size. ActiveRecord gives you that in two methods.

Rajan Bhattarai Rajan Bhattarai 2 min read
« Newer Posts Page 2 of 2
FirstDEV blog © 2026
Proudly published with Jekyll & using Jasper2
Latest Posts Twitter
FirstDEV blog

Check viewARU - Brand Newsletter!

Newsletter to DEVs by DEVs - boost your Personal Brand & career! 🚀