Skip to content

Commit

Permalink
Fix the method signature for transaction helper in `CollectionAssoc…
Browse files Browse the repository at this point in the history
…iation`

The arguments for `transaction` should be `**options`, actually `*args`
is unused though.

And also, the comment is not for the method anymore, the method is not
called from public.
  • Loading branch information
kamipo committed Dec 30, 2020
1 parent c02d9e5 commit be0ab85
Showing 1 changed file with 4 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,6 @@ def concat(*records)
end
end

# Starts a transaction in the association class's database connection.
#
# class Author < ActiveRecord::Base
# has_many :books
# end
#
# Author.first.books.transaction do
# # same effect as calling Book.transaction
# end
def transaction(*args)
reflection.klass.transaction(*args) do
yield
end
end

# Removes all records from the association without calling callbacks
# on the associated records. It honors the +:dependent+ option. However
# if the +:dependent+ value is +:destroy+ then in that case the +:delete_all+
Expand Down Expand Up @@ -315,6 +300,10 @@ def find_from_target?
end

private
def transaction(&block)
reflection.klass.transaction(&block)
end

# We have some records loaded from the database (persisted) and some that are
# in-memory (memory). The same record may be represented in the persisted array
# and in the memory array.
Expand Down

0 comments on commit be0ab85

Please sign in to comment.