RubyFlow The Ruby and Rails community linklog

Wrap your methods with DB Transactions easily

Please check https://github.com/igorkasyanchuk/transactify

You can wrap your methods (class and instance) in transactions. No existing code modifications needed. Just include module and set which methods you want to run in scope of DB transaction.

Put a star if you like an idea! :)

Comments

I don’t think we should put so many logic in AR record models That makes them too “fat”

5 lines of code in my sample so many logic? Of course if creating dummy app with scaffold you won’t have methods with 10+ lines of code, but in real life it’s much more complicated.

I think the gem is helpful, and expresses intent very nicely. I also think Pikachuexe has a point. It’s just how many lines of code, it’s that you have methods on one model responsible for updating several other models. Coordinating changes among several different models is better moved to some kind of PORO instead of picking one of the models to hold it.

I understand, but that was just a sample. Thank you for feedback ;)

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in