なるようになるブログ

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

rails commit log流し読み(2016/04/05)

2016/04/05分のコミットです。

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

activesupport/CHANGELOG.md

activemodel/CHANGELOG.md


Merge pull request #24332 from blackchestnut/doc/deprecation_warn

railties/lib/rails/application/configuration.rbの修正です。

serve_static_filesを使用した場合に出るエラーメッセージのpublic_file_server.enabledについて説明している箇所にconfigを追加しています。

        ActiveSupport::Deprecation.warn <<-eow.strip_heredoc
           `serve_static_files` is deprecated and will be removed in Rails 5.1.
-          Please use `public_file_server.enabled` instead.
+          Please use `config.public_file_server.enabled` instead.
         eow

[ci skip] Fix variable name

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

errors.clearの項のexampleで、使用している変数名をタイポしている箇所があったのを修正しています。


Use QUOTED_TRUE and QUOTED_FALSE instead of magic strings

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

MysqlString#serializeメソッドで、true / falseの変換時にマジックナンバー("1" / "0")を使用していたのを、定義済みの定数(QUOTED_TRUE/QUOTED_FALSE`)を使用するよう修正しています。


it's => its typo

actionpack/CHANGELOG.mdguides/source/5_0_release_notes.mdの修正です。

it's -> itsに修正しています。


Merge pull request #24401 from pan/number-to-phone

Action View / Active Supportの修正です。

number_to_phoneメソッドにformatを指定する為のpatternオプションを使用出来るよう修正しています。

number_to_phone(75561234567, pattern: /(\d{1,4})(\d{4})(\d{4})$/, area_code: true)
# => "(755) 6123-4567"
number_to_phone(13312345678, pattern: /(\d{3})(\d{4})(\d{4})$/)
# => "133-1234-5678"

デフォルトはUS formatのままです。


Merge pull request #24345 from mtsmfm/fix-marshal-with-autoloading-for-nested-class

activesupport/lib/active_support/core_ext/marshal.rbの修正です。

Marshal.loadメソッドで、ネストしたclass / moduleのautoload処理が正しく行えないバグがあったのを修正しています。


Guides changes, follow up of #24401

rails guideのAction View Overviewの修正です。

number_to_phoneメソッドについて説明している箇所に、デフォルトはUS formatである旨説明を追加しています。


Allow passing record being validated to error message generator

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

ActiveModel::Errors::generate_messageメソッドでエラーメッセージを組み立てる際に、I18n.translateメソッドobjectを渡すよう修正しています。

これにより、カスタムエラーメッセージで、オブジェクトの情報が使用出来るようになっています。

Topic.validates_presence_of(:title, message: proc { |record| "You have failed me for the last time, #{record.author_name}." })
t = Topic.new(author_name: 'Admiral')
t.invalid?
t.errors[:title] #=> "You have failed me for the last time, Admiral."

Update documentation based on the new changes for strong & weak ETags [ci skip]

rails guideのCaching with Rails: An Overviewの修正です。

ETagについて説明している箇所に、strong ETagについての説明を追加、weak ETagとstrong ETagについての違いについての説明を追加、等を行なっています。


Added protocol negotiation

Action Cableの修正です。

WebSocketで通信をする際に、protocolを使用するよう修正しています。

Sec-WebSocket-Protocolというヘッダがあるんですねえ。参考:RFC 6455 - The WebSocket Protocol (日本語訳)