なるようになるブログ

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

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

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

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


Extract bind_param and bind_attribute into ActiveRecord::TestCase

Active Recordのテストの修正です。

各テストそれぞれで独自に行っていた、Arel::Nodes::BindParamActiveRecord::Relation::QueryAttributeの生成処理をActiveRecord::TestCaseで行うよう修正しています。


Remove duplicated test_merging_reorders_bind_params

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

重複して存在していたmergeメソッドに関するテストを削除しています。


Should test against Relation#bound_attributes

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

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


Use target language’s document.yaml [ci skip]

guides/rails_guides/helpers.rbの修正です。

rails guidesで各langのdocuments.ymlが正しく読み込まれない(参照する変数名が誤っていた)バグがあったのを修正しています。


Merge pull request #28337 from riseshia/patch-1

guides/rails_guides/generator.rbの修正です。

rails guide用ファイルを出力する際に、出力パスにlangを含む(e.g. langがkoの場合output/ko)よう修正しています。


Move package.json creation to create_root_files

railties/lib/rails/generators/rails/app/app_generator.rbの修正です。

package.jsonの生成処理がvendorメソッドで行われていたのを、create_root_filesメソッドで行うよう修正しています。package.jsonはrootディレクトリ配下に生成されるようになっており、create_root_filesメソッドで行うのが適切な為。


Use mysql2 0.4.6 to suport MySQL 8.0.1

Gemfile.lockの修正です。

mysql2 gemのバージョンを0.4.6に更新しています。0.4.6にMySQL 8.0.1のサポートが入っている為。

参考:Use bool instead of my_bool which has been removed since MySQL 8.0.1


Avoid rubygems 2.6.12 for now

.travis.ymlの修正です。

CIで使用するrubygemsのバージョンを2.6.11にロックしています。2.6.12だとbin/setupのテストが必ず失敗する、という現象が発生している為。

参考:2.6.12: Unable to resolve dependency: user requested ‘io-console (= 0.4.5)’

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

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

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

activerecord/CHANGELOG.md


Add type caster to RuntimeReflection#alias_name

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

RuntimeReflection#alias_nameメソッドでArel::Tableクラスのインスタンスを生成する際に、type_casterオプションを指定するよう修正しています。type_caster(型変換についての情報)の指定が無いとenum等を使用している場合に正しく値が変換されない為。


remove uniqueness validators from ActiveModel examples

activemodel/lib/active_model/validations/validates.rbactivemodel/lib/active_model/validator.rbのdocの修正です。

Active Modelのexampleコードに存在しないuniqueness validatorを使用しているコードがあったのを削除しています。


fix ActiveModel::Validator#kind code examples [ci skip]

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

ActiveModel::Validator#kindメソッドのdocにあるexampleコードが正常に動作しないコードになっていたのを修正しています。

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

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

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


Merge pull request #28753 from st0012/add-render-with-variants-test

Action Viewのテストの修正です。

template/partial + variantsオプションを指定した場合のテストを追加しています。


Merge pull request #28943 from koshigoe/port-arg-has-precedence-over-env-var

railties/lib/rails/commands/server/server_command.rbの修正です。

rails serverにPORT環境変数と"-p"オプションを同時に指定した場合に、"-p"オプションの方を優先するよう修正しています。Rails 5.0までと同じ挙動にする為。


Merge pull request #28930 from kamipo/use_flat_map

activerecord/lib/active_record/reflection.rbactivesupport/lib/active_support/i18n_railtie.rbの修正です。

map + flattenを使用していた箇所を、flat_mapを使用するよう修正しています。


Merge pull request #28938 from kamipo/deprecate_supports_statement_cache

Active Recordの修正です。

supports_statement_cache?メソッドをdeprecateにしています。

supports_statement_cache?メソッドはadapterがprepared statement cachingをサポートしているかどうかをチェックする為のメソッドだったのですが、内部的にはもう使われていない、全てのadapterでtrueを返すようになっている、等の理由でdeprecateになったようです。


Add missing require in ActionMailer

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

不足していたactive_supportのrequireを追加しています。


Rails secrets is not built on but inspired by Sekrets

rails guideのRuby on Rails 5.1 Release Notesの修正です。

Encrypted secretsの項で sekrets gemを使用している、という説明になってしまっていたのですが、実際は使用していない(参考にしただけ)ので、その旨説明を修正しています。

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

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

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


Remove :doc: in :nodoc: class [ci skip]

actionpack/lib/action_dispatch/journey/router/utils.rbのdocの修正です。

:nodoc:が設定されているクラスのメソッドに:doc:が設定されていたのを削除しています。クラス自体に:nodoc:が設定されている場合、メソッドに:doc:を設定してもdocは生成されない為。


Friendly maintain schema failure

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

テスト実行時にActiveRecord::PendingMigrationErrorが発生した場合に、他のエラー同様にバックトレースを全て表示していたのを、エラーメッセージだけ表示するよう修正しています。

before

before

after

after

バックトレースがそのまま表示されるとエラーメッセージを確認するのが大変な為、PendingMigrationErrorの場合はエラーメッセージだけを表示するようにしたとの事です。


Remove unnecessary package.json deletion

railties/lib/rails/generators/rails/app/app_generator.rbの修正です。

create_vendor_filesメソッドから不要なpackage.jsonの削除処理を削除しています。package.jsonskip_yarnfalseが設定された場合しか作成されず、明示的に削除する必要は無い為。


Update the Gem Bug Report Templates to 5.1.0

Bug Report Templates で使用するrailsのバージョンを5.1.0に更新しています。

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

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

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


Cleanup CHANGELOGs [ci skip]

CHANGELOGの修正です。

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


Fix note about secrets.yml [ci skip]

rails guideのA Guide for Upgrading Ruby on Railsの修正です。

secrets.ymlのkeyを全てsymbolとして読み込むようにした対応についての説明で、exampleコードに誤りがあったのを修正しています。


Add docs for Router::Utils.unescape_uri method

actionpack/lib/action_dispatch/journey/router/utils.rbのdocの修正です。

Router::Utils.unescape_uriメソッドにdocを追加しています。


Add period

actionpack/lib/action_dispatch/journey/router/utils.rbのdocの修正です。

Router::Utils.unescape_uriメソッドのdocの終端にピリオドを追加しています。

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

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

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


Add missing require for remove_possible_method

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

不足していたactive_support/core_ext/module/remove_methodのrequireを追加しています。


Stop creating duplicate Struct instances

activerecord/test/cases/log_subscriber_test.rbの修正です。

各テストで共通で使用するStructを、テストロード時に定義するよう修正しています。


Remove entries included in 5.0 [ci skip]

rails guideのRuby on Rails 5.1 Release Notesの修正です。

Rails 5.0に含まれている対応が変更点に含まれていたので、削除しています。

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

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

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

actionview/CHANGELOG.md


Add documentation of data attributes for UJS [ci skip]

rails guideのWorking with JavaScript in Railsの修正です。

rails-ujsでのdata attributes(data-methoddata-disable-with等)の指定の方法や扱われか方等についての説明を追加しています。


Evaluate belongs_to :default option against the owner, not the association

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

belongs_todefaultオプションに指定したblockを実行する際、associationに対して実行していたのを、associationが定義されているmodelの元で実行するよう修正しています。

PRより。

# app/models/ship.rb
class Ship < ApplicationRecord
  belongs_to :developer, default: -> { default_developer }

  def default_developer
    Developer.first
  end
end

というクラスがあった場合に、

# before
ship = Ship.create!
NameError: undefined local variable or method `default_developer' for #<ActiveRecord::Associations::BelongsToAssociation:0x0056312d94b8d0>

# after
ship = Ship.create!
# => #<Ship id: 1, developer_id: 1>

のように、modelで定義したメソッドが呼べるようになっています。


Also raise error when VERSION is nil

activerecord/lib/active_record/railties/databases.rakeの修正です。

VERSION envを指定せずにdb:migrate:updb:migrate:downを実行してもエラーにならないバグがあったのを修正しています。


Ensure input to distance_of_time_in_words is not nil

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

distance_of_time_in_wordsメソッドの引数に不正な値(nil等)を指定した場合のエラーメッセージの改善、及び、from_timeto_time引数にTime / Date objectとNumericが混在した場合に正常に動作するよう修正しています。

# before

helper.time_ago_in_words(nil)
# => NoMethodError: undefined method `>' for nil:NilClass

helper.distance_of_time_in_words(Date.current, 0)
# => NoMethodError: undefined method `/' for 2017-04-28 00:00:00 +0900:Time


# after

helper.time_ago_in_words(nil)
# => ArgumentError: nil can't be converted to a Time value

helper.distance_of_time_in_words(Date.current, 0)
# => "over 47 years"

Merge pull request #28844 from kyuden/remove_unnecessary_attributes_of_select_in_form_with

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

form_withが生成するformの中でselectタグを生成する際に、不要なskip_default_idsallow_method_names_outside_object attributesが付与されてしまっていたのを、付与されないよう修正しています。


Added some more release notes for Active Record [ci skip]

rails guideのRuby on Rails 5.1 Release Notesの修正です。

Active Recordの項にエントリーを追加しています。


Fix indentation [ci skip]

rails guideのRuby on Rails 5.1 Release Notesの修正です。

Active Recordの項のエントリーのインデントがずれていたのを調整しています。


Small grammar fixes

rails guideのWorking with JavaScript in Railsの修正です。

グラマーの修正を行っています。


Small grammar fix

rails guideのRuby on Rails 5.1 Release Notesの修正です。

グラマーの修正を行っています。


5.1 Release Notes are complete [ci skip]

guides/source/documents.yamlの修正です。

Ruby on Rails 5.1 Release NotesからWIPを削除し、リリースしています。