なるようになるブログ

読書感想文かrailsについてかrubyについてか

rails commit log流し読み(2018/01/24)

2018/01/24分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

actionmailer/CHANGELOG.md

activemodel/CHANGELOG.md

activejob/CHANGELOG.md


Merge pull request #30391 from jbourassa/fix-actionmailer-lambda-default

actionmailer/lib/action_mailer/base.rbの修正です。

ActionMailer::Base.defaultに引数が一つのProcを指定できなくなっていたのを、再度指定出来るよう修正しています。


Allow attributes with a proc default to be marshalled

activemodel/lib/active_model/attribute/user_provided_default.rbの修正です。

attributes APIを使用している、かつ、defaultにProcを使用しているオブジェクトをMarshal.dumpでダンプするとエラーになっていたのを、エラーなくダンプ、及び、ロード出来るよう修正しています。


Merge pull request #30622 from aidanharan/custom-discarded-job-handling

activejob/lib/active_job/exceptions.rbの修正です。

ActiveJob::Base.discard_onにblockを指定出来るよう修正しています。ブロックの引数にはjobと発生したexceptionが渡されるようになっています。

class RemoteServiceJob < ActiveJob::Base
  discard_on(CustomAppException) do |job, exception|
    ExceptionNotifier.caught(exception)
   end

  def perform(*args)
    # Might raise CustomAppException for something domain specific
  end
end

Clarification for noobs. (#31704)

rails guideのActive Record BasicsContributing to Ruby on Railsの修正です。

グラマーやフォーマットの修正、w3schoolssqlcourseへのリンク等を追加しています。


tweaks for #31704 [ci skip]

rails guideのActive Record Basicsの修正です。

フォーマットの修正を行っています。


Fix CHANGELOG format [ci skip]

activejob/CHANGELOG.mdの修正です。

メソッド名にバッククォートを追加、及び、exampleコードのインデントがずれていたのを修正しています。


Use concat to join procs arrays in bulk_change_table

activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rbの修正です。

alter_table blockにcommentを指定した場合にエラーになってしまうバグがあったのを修正しています。


Merge pull request #31422 from Edouard-chin/multistatement-fixtures

Active Recordの修正です。

fixturesをinsertする際に、multi statement queryを使用するよう修正しています。

これにより、元々はtable毎にqueryを実行していたのを、一つのqueryでまとめてデータを作成(削除も)するようになっています。


Make discard safe when it follows a manual disconnect

activerecord/lib/active_record/connection_adapters/postgresql_adapter.rbの修正です。

PostgreSQLAdapter#discard!メソッドでsocketのreopenでエラーになっても、エラーをにぎりつぶすよう修正しています。

      def discard! # :nodoc:
-        @connection.socket_io.reopen(IO::NULL)
+        @connection.socket_io.reopen(IO::NULL) rescue nil
         @connection = nil
       end

forkした子プロセスがdisconnectする際、親がsocketをclose済みの場合に上記箇所でエラーになってしまっていたのですが、socketがclose済みでもdisconetには問題無い為、エラーをにぎりつぶすようにしています。