Coder Social home page Coder Social logo

pat / after_commit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gui/after_commit

63.0 63.0 32.0 90 KB

A Ruby on Rails plugin to add an after_commit callback. This can be used to trigger things only after the entire transaction is complete.

License: MIT License

Ruby 100.00%

after_commit's Introduction

Hullo πŸ‘‹πŸ»

  • 🌏 Based in Narrm (also known as Melbourne, Australia)
  • πŸ‘¨πŸΌβ€πŸ’» Pronouns are he/him
  • πŸ•ΈοΈ Working on the web for over 20 years.
  • ❀️ Coding in Ruby for over 15 years.
  • ✍🏻 Occasionally writing at https://freelancing-gods.com
  • πŸ€” Posting regularly to Mastodon
  • πŸ“† Built Calm Calendar, Flying Sphinx, and Support Act
  • 🎀 Organised some editions of RubyConf AU, Rails Camp, and Trampoline
  • 🍦 Eating a lot of gelato
  • πŸ₯ž Cooking a lot of pancakes

after_commit's People

Contributors

delynn avatar dmexe avatar flyerhzm avatar ivantsepp avatar jasoncodes avatar kir avatar mocoso avatar nickblah avatar nirvdrum avatar ochko avatar oggy avatar pat avatar rlineweaver avatar thieso2 avatar trotter avatar xaviershay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

after_commit's Issues

Allow inline after_commit do blocks <-> make ar_after_transaction obsolote

I have a similar project (ar_after_transaction)[https://github.com/grosser/ar_after_transaction] that fixes the same problems, but also adds a after_transaction do block style callback, so users can e.g.

after_create :do_stuff, :oops

def do_stuff
  after_transaction do
    send_an_email # cannot be rolled back
  end
  comments.create(...) # will be rolled back
end

Is it possilbe to include this behavior -> id like to mark the project as obsolete and just link here.

after_commit_on_update with multiple updates to the same object per transaction

This issue is really biting us in the butt. I'm happy to commit a change to fix this, but I wanted to get some perspective before I do.

Here's the issue we're having:

we have a after_commit_on_update callback for a model. I've changed the callback to just print when it is called. Inside our code, we do something similar to this (of course these updates aren't right next to each other).

User.transaction do
  user.update_attribute(:first_name, "asdf")
  user.update_attribute(:last_name, "fdsa")
end

Will result in

CALLING COMMIT UPDATE
CALLING COMMIT UPDATE

Now, I admit that we probably shouldn't be doing these things, but we are, and it's hard to go through a relatively large codebase to fix these double-updated.

I think it makes sense to make the :committed_records_on_update collection only have one instance of an object in the collection, no matter how many times the object was updated inside the transaction. Thoughts?

1.0.9 breaks my tests... fixed it by adding gem "after_commit", "1.0.8"

I recently did a gem update... and 1.0.9 installed itself

Then all my tests broke with reuse of transaction messages and failure to reset Sham.

I'm using test::unit with transactional fixtures and Machinist (in case that matters)

i've fixed the version at 1.0.8 in my Gemfile and I'm back in action.

This could be related to the change in dependency ... my Gemfile.lock says activerecord < 3.0.0 with 1.0.8, but < 3.0.0, >=1.15.6 with 1.0.9.

so... to fix my test breakage i added this line to Gemfile
gem "after_commit", "1.0.8"

before this trouble, after_commit was only added as a dependency and was not explicitly listed.

activerecord-jdbc-adapter 1.2.1 breaks compatibility

ArJdbc 1.2.0 works, but 1.2.1 gives me this traceback:

$ script/server -e production -p 3002
=> Booting Mongrel
=> Rails 2.3.14 application starting on http://0.0.0.0:3002

NameError: undefined method `commit_db_transaction' for module `ArJdbc::MySQL'
                     alias_method at org/jruby/RubyModule.java:2221
               alias_method_chain at /Users/nilbus/.rvm/gems/jruby-1.6.5@robertson/gems/activesupport-2.3.14/lib/active_support/core_ext/module/aliasing.rb:33
                         included at /Users/nilbus/.rvm/gems/jruby-1.6.5@robertson/gems/after_commit-1.0.10/lib/after_commit/connection_adapters.rb:74
                      module_eval at org/jruby/RubyModule.java:2242
                         included at /Users/nilbus/.rvm/gems/jruby-1.6.5@robertson/gems/after_commit-1.0.10/lib/after_commit/connection_adapters.rb:4
                          include at org/jruby/RubyModule.java:2083
                             send at org/jruby/RubyKernel.java:2097
   include_after_commit_extension at /Users/nilbus/.rvm/gems/jruby-1.6.5@robertson/gems/after_commit-1.0.10/lib/after_commit/active_record.rb:29
  include_after_commit_extensions at /Users/nilbus/.rvm/gems/jruby-1.6.5@robertson/gems/after_commit-1.0.10/lib/after_commit/active_record.rb:20
                           (root) at /Users/nilbus/.rvm/gems/jruby-1.6.5@robertson/gems/after_commit-1.0.10/lib/after_commit.rb:81
                          require at org/jruby/RubyKernel.java:1038
                          require at /Users/nilbus/.rvm/gems/jruby-1.6.5@robertson/gems/activesupport-2.3.14/lib/active_support/dependencies.rb:184
                           (root) at /Users/nilbus/.rvm/gems/jruby-1.6.5@robertson/gems/after_commit-1.0.10/lib/after_commit.rb:2
                          require at org/jruby/RubyKernel.java:1038
                          require at /Users/nilbus/.rvm/gems/jruby-1.6.5@robertson/gems/thinking-sphinx-1.3.14/lib/thinking_sphinx.rb:68

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.