---
title: "Discussion on \"Refactoring transaction blocks with the endless method\" | Hashnode"
description: "Discussion on \"Refactoring transaction blocks with the endless method\". Explore refactoring Rails transaction blocks with the endless method. Pros and cons, examples from Maybe and Mastodon, and community feedback"
url: "https://hashnode.com/posts/refactoring-transaction-blocks-with-the-endless-method/6673d0e5f3a9e4bdb601ba3b"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Refactoring transaction blocks with the endless method](https://codeandgit.hashnode.dev/refactoring-transaction-blocks-with-the-endless-method?utm_source=hashnode&utm_medium=feed)

Explore refactoring Rails transaction blocks with the endless method. Pros and cons, examples from Maybe and Mastodon, and community feedback

Jun 20, 2024 · 8 min read · codeandgit.hashnode.dev  
Updated Jun 21, 2024  
Read the article

-   [#ruby](https://hashnode.com/tag/ruby)
-   [#ruby-on-rails](https://hashnode.com/tag/ruby-on-rails)
-   [#programming-blogs](https://hashnode.com/tag/programming-blogs)
-   [#refactoring](https://hashnode.com/tag/refactoring)

## Written by

[Lucian Ghinda](https://hashnode.com/@lucianghinda)

@lucianghinda · Europe

  
[View profile](https://hashnode.com/@lucianghinda)

Senior Product Engineer

Senior Product Engineer, working in Ruby and Rails. Passionate about idea generation, creativity, and programming. I curate the Short Ruby Newsletter.

## Responses 3

Markdown supported · ⌘↵ to post

[Mark Linda](https://hashnode.com/@Linda343)

[Jun 22, 2024](https://hashnode.com/posts/refactoring-transaction-blocks-with-the-endless-method/6673d0e5f3a9e4bdb601ba3b/comment/66775ceb746658709617af8b)

I can teach you how to turn your $200 into $8,500 in 2hours without interrupting your daily activities and it's 100% legitimate and secure TEXT ME IF YOU ARE INTERESTED FOR MORE INFORM WITH THE DETAILS BELOW

WHATSAPP NO: ‪+1 (774) 493‑3224

[Peter Sumskas](https://hashnode.com/@PeterSumskas)

[Jun 22, 2024](https://hashnode.com/posts/refactoring-transaction-blocks-with-the-endless-method/6673d0e5f3a9e4bdb601ba3b/comment/6676385e6c9716cfa7c72469)

It’s an interesting exploration. I’m not quite in favour of it. I reckon that in a busy codebase the `= transaction do` will be easy to miss, while the extra block is clearer.

I don’t think the goal should be “less lines” rather it should be “more clarity”.

If I wanted to “wrap” things in transactions then I might lean towards meta-programming 😱 and have a class method that takes a symbol of the method name and wrap that in a transaction by renaming the method. E.g `transaction def update_fnargle …`

But I’d think long and hard if that is enough of a gain in clarity before I lean on either technique.

[Lucian Ghinda](https://hashnode.com/@lucianghinda)

[Jul 9, 2024](https://hashnode.com/posts/refactoring-transaction-blocks-with-the-endless-method/6673d0e5f3a9e4bdb601ba3b/comment/6676385e6c9716cfa7c72469#reply-668d22a35224655481ed1ddd)

I agree that this is not the type of code that one can find usually. This is why I wanted to explore some refactoring with it and see how it looks/feels like.

I also agree with you that I will not go to meta-programming as an alternative very easy even if maybe it will promote the `transaction` keyword in front and more visible

[Priya Raimagiya](https://hashnode.com/@priyaraimagiya123)

[Jun 21, 2024](https://hashnode.com/posts/refactoring-transaction-blocks-with-the-endless-method/6673d0e5f3a9e4bdb601ba3b/comment/6675a55d74665870960e90e8)

Thank you for sharing!

[Abhay Pansuriya](https://hashnode.com/@mrPansuriya)

[Jun 27, 2024](https://hashnode.com/posts/refactoring-transaction-blocks-with-the-endless-method/6673d0e5f3a9e4bdb601ba3b/comment/6675a55d74665870960e90e8#reply-667cf41dda991fb560866269)

Test Post commnet

[Abhay Pansuriya](https://hashnode.com/@mrPansuriya)

[Jun 27, 2024](https://hashnode.com/posts/refactoring-transaction-blocks-with-the-endless-method/6673d0e5f3a9e4bdb601ba3b/comment/6675a55d74665870960e90e8#reply-667cf43609f69aca745eb977)

Hi
