なるようになるブログ

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

rails commit log流し読み(2017/10/09)

2017/10/09分のコミットです。

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

actioncable/CHANGELOG.md

activejob/CHANGELOG.md

railties/CHANGELOG.md


Merge pull request #30802 from khall/30662_long_variant_filenames

activestorage/app/models/active_storage/variant.rbの修正です。

keyを生成する際に、keyそのままではなく、ハッシュ値(Digest::SHA256.hexdigestを使用)を使用するよう修正しています。

  def key
-    "variants/#{blob.key}/#{variation.key}"
+    "variants/#{blob.key}/#{Digest::SHA256.hexdigest(variation.key)}"
   end

keyをそのまま使用すると、生成されたファイル名が長い場合にErrno::ENAMETOOLONGのエラーが発生してしまう可能性がある為。


Merge pull request #30789 from erichmachado/file-store-cache-cleanup-fix

activesupport/lib/active_support/cache/file_store.rbの修正です。

ActiveSupport::Cache::FileStore#cleanupでexpireしかファイルが実際には削除されないバグがあったのを修正しています。


Distinguish missing adapter gems from load errors within the adapter

actioncable/lib/action_cable/server/configuration.rbactiverecord/lib/active_record/connection_adapters/connection_specification.rbの修正です。

Action Cable、及び、Active Recordで指定されたadapterに対応するgemが見つからない場合(adapterにPostgreSQLを指定しているがpg gemをGemfileに指定していない場合等)に、エラーメッセージに詳細な情報を出力するよう修正しています。


redis-rb 4.0 support

Action Cable、Active Job、railtiesの修正です。

Action Cable、Active Jobがredis-rb 4系で動作するよう修正しています(Active Jobはテストの修正だけ)。

合わせて、rails newで生成されるGemfileでredis-rb 4系を使用するよう修正しています。


Remove passing redundant self to internal apply_join_dependency etc

activerecord/lib/active_record/relation/finder_methods.rbの修正です。

ActiveRecord::FinderMethods#construct_relation_for_exists#apply_join_dependencyメソッドの引数から、不要なrelation引数を削除しています。同じクラスからしか呼ばれないメソッドであり、レシーバーの明示的な指定は不要な為。


Fix typo in loading error message

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

指定されたadapterに対応するgemが見つからない場合に表示するエラーメッセージでタイポしていたのを修正しています。


Missing revision 5efd21bb7ee4b326d9c0d26fccad10fc59dd51f0 in redis-rb-4.0 branch

Gemfile.lockの修正です。

resque-scheduler gemを使用するのにGitHubリポジトリ(https://github.com/jeremy/resque-scheduler)を直接指定しているのですが、そののリポジトリrevisionの指定に誤りがあったのを修正しています。どうやらコミットした後からrebaseしたもよう。


Fix relation.exists? with has_many through associations

activerecord/lib/active_record/relation/finder_methods.rbの修正です。

has_many through associationをjoinした際に、relation.exists?メソッドが正しいaliasを参照しないバグがあったのを修正しています。


Fix the result of rails routes in Guide [ci skip]

rails guideのGetting Started with Railsの修正です。

rails routesの実行結果のexampleが、実際の内容と異なっていたのを修正しています。


Remove meaningless named construct_relation_for_association_calculations

activerecord/lib/active_record/relation/calculations.rbactiverecord/lib/active_record/relation/finder_methods.rbの修正です。

FinderMethods#construct_relation_for_association_calculationsメソッドを削除しています。

上記メソッドはjoin dependencyのapply処理のラップ(apply_join_dependencyメソッドを呼び出すだけ)しか行っていない、かつ、内部でだけ使用するメソッドなので、apply_join_dependencyメソッドを直接呼び出した方がわかりやすいだろう、という事で削除されたようです。


Use form_with instead of form_for in engine guide [ci skip]

rails guideのAction Controller OverviewGetting Started with Enginesの修正です。

form_forメソッドを使用していた箇所をform_withメソッドを使用するよう修正しています。


All test cases for exists? places in finder_test.rb to ease to find the test cases

activerecord/test/cases/finder_test.rbactiverecord/test/cases/relations_test.rbの修正です。

exists?メソッドに関するテストを全てactiverecord/test/cases/finder_test.rbに移動しています。

元々finder_test.rbに殆どのテストがあって、一部テストだけrelations_test.rbにある状態でした。それだとわかりずらいだろうという事でfinder_test.rbに移動したようです。


Joined tables in association scope doesn't use the same aliases with the parent relation's aliases

Active Recordの修正です。

join dependencyのassociation scopeを生成する際に、親relationのaliasを参照出来るよう修正しています。親relationで定義されているaliasと同じaliasを定義するのを避ける為(同じaliasがあるとエラーになる)、のようです。


Use released sidekiq instead of master version

Gemfileの修正です。

sidekiqを使用するのにGitHubのmaterブランチを直接指定していたのを、リリース済みのgemを使用するよう修正しています。

rails commit log流し読み(2017/10/08)

2017/10/08分のコミットです。

CHANGELOGへの追加はありませんでした。


Fix default of String#to_time [ci skip]

rails guideのActive Support Core Extensionsの修正です。

String#to_timeメソッドのデフォルト値についての説明が誤っていたのを修正しています。


Merge pull request #30831 from masatooba/fix-radio-button-tag-comment

actionview/lib/action_view/helpers/form_tag_helper.rbのdocの修正です。

radio_button_tagメソッドのdoc内、radio_button_tagの第二引数にピリオドやセミコロンを含む値を指定した場合のexampleの結果が実際の結果と異なっていたのを修正しています。


Decouple building AliasTracker from JoinDependency

Active Recordの修正です。

AliasTrackerの生成処理をAssociations::JoinDependencyクラスから分離しています。

親のrelationのalias trackingを参照出来るようにする為の準備、との事です。


Exception message for SystemTestCase#get etc..

actionpack/lib/action_dispatch/system_testing/test_helpers/undef_methods.rbの修正です。

System Testでhttp verb method(getpost等)を使用した際のエラーメッセージに詳細な情報(e.g. System tests cannot make direct requests via #get; use #visit and #click_on instead. See http://www.rubydoc.info/github/teamcapybara/capybara/master#The_DSL for more information.)を含むよう修正しています。

rails commit log流し読み(2017/10/07)

2017/10/07分のコミットです。

CHANGELOGへの追加はありませんでした。


Add v5.1 to earlier releases list in guide [ci skip]

guides/source/_welcome.html.erbの修正です。

rails guideの一覧にRails 5.1のguideへのリンクを追加しています。


Remove needless setup from InfoTest

railties/test/rails_info_test.rbの修正です。

Rails::Infoのテストから、不要な前処理を削除しています。


Update Instrumentation guide for Active Storage [ci skip]

rails guideのActive Support Instrumentationの修正です。

Active Storageのセクションを追加し、Active Storageのhooksについての説明を追加しています


[ci skip] Fix typo

rails guideのActive Support InstrumentationConfiguring Rails Applicationsの修正です。

you application -> your applicationに修正しています。

rails commit log流し読み(2017/10/06)

2017/10/06分のコミットです。

CHANGELOGへの追加はありませんでした。


Move duplicated code to delete_or_destroy in CollectionAssociation

activerecord/lib/active_record/associations/collection_association.rbの修正です。

CollectionAssociation#delete#destroyメソッドそれぞれで行っていた共通の処理を、#delete_or_destroyメソッドで行うよう修正しています。


Merge pull request #30809 from meganemura/use-callee

activerecord/lib/active_record/relation/query_methods.rbの修正です。

left_outer_joinsメソッドでcheck_if_method_has_arguments!メソッドを呼び出す際に、引数にメソッド名(:left_outer_joins)を直接指定していたのを、__callee__を指定するよう修正しています。

left_outer_joinsのaliasメソッド(left_joins)を使用した際に、エラーメッセージに正しくメソッド名が表示されるようにするため。


request check

actionview/lib/action_view/helpers/asset_tag_helper.rbの修正です。

javascript_include_tagstylesheet_link_tagメソッドでearly hintsを送信する際に、requestインスタンスが存在するかどうかチェックするよう修正しています。


Cosmetic fixes [ci skip]

rails guideの修正です。

各guide内のメソッド名や定数名等をバッククォートで囲むよう修正しています。

rails commit log流し読み(2017/10/05)

2017/10/05分のコミットです。

CHANGELOGへの追加はありませんでした。


Extract repeatedly appeared prepending compatible table definition

activerecord/lib/active_record/migration/compatibility.rbの修正です。

各メソッドで独自に行っていたTableDefinitionのprepend処理をメソッドに切り出しています。


Add JSON attribute test cases for SQLite3 adapter

Active Recordの修正です。

SQLite3 adapterでJSON attributeを使用した場合のテストを追加しています。


Merge pull request #30702 from rmachielse/patch-1

actioncable/lib/action_cable/connection/subscriptions.rbの修正です。

Connection::Subscriptions#removeメソッドで、subscriptionを取得するのにfindメソッドを使用するよう修正しています。subscriptionを取得出来ない場合のエラーメッセージに詳細な情報が出るようにする為。

before

Could not execute command from ({"command"=>"unsubscribe", "identifier"=>"{\"channel\":\"SomeChannel\"}"}) [NoMethodError - undefined method `unsubscribe_from_channel' for nil:NilClass]:
/app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/connection/subscriptions.rb:48:in `remove_subscription'
/app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/connection/subscriptions.rb:44:in `remove'
/app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/connection/subscriptions.rb:16:in `execute_command'
/app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/connection/base.rb:85:in `dispatch_websocket_message' /app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/server/worker.rb:58:in `block in invoke'

after

Could not execute command from ({"command"=>"unsubscribe", "identifier"=>"{\"channel\":\"SomeChannel\"}"}) [RuntimeError - Unable to find subscription with identifier: {"channel":"SomeChannel"}]:
/app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/connection/subscriptions.rb:76:in `find'
/app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/connection/subscriptions.rb:44:in `remove'
/app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/connection/subscriptions.rb:16:in `execute_command'
/app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/connection/base.rb:85:in `dispatch_websocket_message'
/app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/server/worker.rb:58:in `block in invoke

rails commit log流し読み(2017/10/04)

2017/10/04分のコミットです。

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

actionpack/CHANGELOG.md


Fix third-party system libraries list in ActiveStorage::Preview [ci skip]

activestorage/app/models/active_storage/preview.rbのdocの修正です。

ActiveStorage::Previewクラスのdoc内、デフォルトのpreview機能で依存しているライブラリのリストに、不要なスペースがあったのを削除してみあす。


Prefer official name PostgreSQL over Postgres

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

Postgres -> PostgreSQLに修正しています。


Cleanup CHANGELOGs [ci skip]

CHANGELOGの修正です。

不要なスペースの削除、フォーマットの修正等をまとめて行っています。


Fix formatting of Time.use_zone [ci skip]

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

Time.use_zoneメソッドのdoc内の注意事項について記載している箇所に不要なスペースがあったのを削除しています。


Merge pull request #30734 from oreoshake/patch-1

rails guideのLayouts and Rendering in Railsの修正です。

Rendering HTMLの項でhtmlオプションを使用する例でhtmlタグを直接renderしていたのを、helper method(tag method)を使用するよう修正しています。


Implement H2 Early Hints for Rails

Action Packの修正です。

HTTP/2のEarly Hintsのサポートを追加として、Early Hintsの情報を送るためのsend_early_hintsメソッドを追加、及び、javascript_include_tagstylesheet_link_tagメソッドの結果に自動でEarly Hintsを入れるようにしています(requestがあった場合)。

サーバ側でもEarly Hintsがサポートされていないと使えないのですが、現状Pumaにはサポートが入っています(Implement H2 Early Hints for Rails)。なお、デフォルトEarly Hintsの使用はされないようになっており、rails server起動時に--early-hintsオプションを指定してあげる必要があります。

参考:

rails commit log流し読み(2017/10/03)

2017/10/03分のコミットです。

CHANGELOGへの追加はありませんでした。


rails-ujs: Update README

actionview/app/assets/javascripts/README.mdの修正です。

README全体のフォーマットや言い回しの修正等を行っています。


Add test case for font_url

actionview/test/template/asset_tag_helper_test.rbの修正です。

font_urlメソッドについてのテストを追加しています。


Associate blobs with their attachments

activestorage/app/models/active_storage/blob.rbの修正です。

ActiveStorage::Blobクラスからattachmentsへのassociation(has_many :attachments)を設定しています。