2016/01/28分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
Merge pull request #21791 from sonalkr132/persistence-doc
activerecord/lib/active_record/persistence.rb
のdocの修正です。
ActiveRecord::Persistence
moduleのdocのグラマーの修正を行っています。
Fix typos in asset_pipeline.md
rails guideのThe Asset Pipeline
の修正です。
guide内に複数あったタイポをまとめて修正しています。
Update ActiveJob adapter for sucker_punch 2.0
Active Jobの修正です。
sucker_punch
2.0のAPIに合わせてSuckerPunchAdapter
クラスを修正しています。
sucker_punch
2.0では、async.perform
がperform_async
に変更、及び遅延処理用のメソッド(perform_in
)が追加されており、これによりsucker_punch
でもenqueue_at
メソッドが使用出来るようになっています。
Do not use default attributes for STI when instantiating a subclass
activerecord/lib/active_record/inheritance.rb
の修正です。
STIを使用している、かつ、type
にデフォルト値を設定しているクラスがある場合に、その子クラスのインスタンス生成処理でエラーになってしまうバグがあったのを修正しています。
issueより。
ActiveRecord::Schema.define do create_table :resources, force: :cascade do |t| t.string :type, null: false, default: 'Resource' t.datetime :created_at, null: false t.datetime :updated_at, null: false end end class Resource < ActiveRecord::Base end class Channel < Resource end Channel.new # => ActiveRecord::SubclassNotFound: Invalid single-table inheritance type: Resource is not a subclass of Channel
子クラスのインスタンス生成時には、defaultの値を使用しないよう対応しています。
Fix img alt attribute generation when using Sprockets >= 3.0
actionview/lib/action_view/helpers/asset_tag_helper.rb
の修正です。
Sprockets 3系ではdigestの生成にMD5ではなくSHA256を使用するようになりました。その為、生成digestの桁数が64桁になったのですが、image_alt
メソッドでその事の考慮が入っていなかった為、digestが64桁でも正しくaltを生成出来るよう修正しています。
def image_alt(src) - File.basename(src, '.*'.freeze).sub(/-[[:xdigit:]]{32}\z/, ''.freeze).tr('-_'.freeze, ' '.freeze).capitalize + File.basename(src, '.*'.freeze).sub(/-[[:xdigit:]]{32,64}\z/, ''.freeze).tr('-_'.freeze, ' '.freeze).capitalize end
Fix typo in strong params hash deprecation message
actionpack/lib/action_controller/metal/strong_parameters.rb
の修正です。
StrongParameter
で使用できなくなったメソッドを使用した場合に出力されるdeprecatedメッセージで、vulnerability
をvulunerability
にタイポしている箇所があったのを修正しています。
actionview/test/template/asset_tag_helper_test.rb
の修正です。
先ほどコミットされたimage_alt
の対応について、テストを追加しています。
Remove celluloid from the Gemfile
Gemfileの修正です。
先ほどコミットされたsucker_punch
の2.0対応で、誤ってGemfileにcelluloid
追加されてしまったので、削除しています。
Update sucker_punch adapter's description
activejob/lib/active_job/queue_adapters/sucker_punch_adapter.rb
のdocの修正です。
SuckerPunchAdapter
クラスのdoc内に、celluloid
を使用している旨説明があったのですが、sucker_punch
2系dではcelluloid
を使用していないで、該当箇所を修正しています。
change @text_xml_idx
to an lvar and cache it on the stack
actionpack/lib/action_dispatch/http/mime_type.rb
の修正です。
text/xml
のindex管理にインスタンス変数を使用していたのを、ローカル変数を使用するよう修正しています。
インスタンス変数の参照はメソッド経由で行っており、値が初期化されてるかどうかの確認の為毎回||=
が実行されていたのですが、この対応によりインスタンス変数を減らせる + ||=
のチェックも無くせる為との事です。
change @app_xml_idx
to an lvar and cache it on the stack
actionpack/lib/action_dispatch/http/mime_type.rb
の修正です。
Mime[:xml]
のindex管理にインスタンス変数を使用していたのを、ローカル変数を使用するよう修正しています。 上記はほぼ同上。
remove useless private methods
actionpack/lib/action_dispatch/http/mime_type.rb
の修正です。
[]
メソッドのaliasとしてtext_xml
、app_xml
メソッドを定義していたのを削除し、[]
メソッドを使用するよう修正しています。
Mime::Type::AcceptItem#==
メソッドを削除しています。
Mime::Type::AcceptItem#==
メソッドではname
の比較処理のみ行っており、オブジェクトの同一性のチェックを行ってない、かつ、nameからitemを取得したい時にだけ利用しており、それようの別メソッドを作成すれば済む為、別途find_item_by_name
メソッドを追加し、Mime::Type::AcceptItem
は削除を行っています。
English explanation to multi-level nested join
rails guideのActive Record Query Interface
の修正です。
Joining Nested Associations (Multiple Level)
の項に、他の項同様に英語でのJOIN処理の説明を追加しています。
Merge pull request #18928 from bogdan/unreversable-order
activerecord/lib/active_record/relation/query_methods.rb
の修正です。
ActiveRecord::Relation#reverse_order
がreverse出来ない場合、及びprimary keyが無いテーブルで対してメソッドを使用した場合に、ActiveRecord::IrreversibleOrderError
をthrowするよう修正しています。
元々、ActiveRecord::Relation#reverse_order
はとてもシンプル実装になっており、正しく実行出来ないようなSQLを生成してしまう事もあったのですが、多少厳密にチェックを行い、単純にreverse出来ないような処理の場合に、不正なSQLを生成する代わりにエラーをthrowするように処理が変更になっています。
例(CHANGELOGより)。
Topic.order("concat(author_name, title)").reverse_order # Before: SELECT `topics`.* FROM `topics` ORDER BY concat(author_name DESC, title) DESC # After: raises ActiveRecord::IrreversibleOrderError Edge.all.reverse_order # Before: SELECT `edges`.* FROM `edges` ORDER BY `edges`.`` DESC # After: raises ActiveRecord::IrreversibleOrderError
Consistently warn that passing an offset to find_nth
is deprecated
activerecord/lib/active_record/relation/finder_methods.rb
の修正です。
Merge pull request #22053 from Empact/first-loaded · rails/rails@0d2675fでfind_nth
にoffset
を渡すのがdeprecateになったのですが、recordがload済みの場合にfind_nth
にoffset
を渡した場合でもdeprecated messageが出ないようになってしまっていました。
で、これを、recordがload済みの場合にもdeprecated messageを出すよう修正しています。
activesupport/lib/active_support/core_ext/module/deprecation.rb
のdocの修正です。
deprecate
メソッドのdoc内のexampleのインデントがおかしくなっていたのを修正しています。
Merge pull request #23237 from gsamokovarov/new-welcome-page
railtiesの修正です。
welcome pageのデザインをリニューアルしています。
old
new
大分シンプルなページになりました。
Fix a bug with initialize schema_migrations table
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
の修正です。
schema_migrations
テーブル用のinsert分のエスケープ処理に誤りがあり、データ挿入時にエラーになってしまうバグがあったのを修正しています。
- execute "INSERT INTO #{sm_table} (version) VALUES #{inserting.map {|v| '(#{v})'}.join(', ') }" + execute "INSERT INTO #{sm_table} (version) VALUES #{inserting.map {|v| "('#{v}')"}.join(', ') }"