2015/02/19分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Add
timeoption to#touch - Add ActiveRecord::Base.suppress to prevent the receiver from being saved during the given block.
activemodel/CHANGELOG.md
- Deprecate
ActiveModel::Errors#get,ActiveModel::Errors#setandActiveModel::Errors#[]=methods that have inconsistent behaviour. - Deprecate
ActiveModel::Errorsadd_on_emptyandadd_on_blankmethods
activerecord/lib/active_record/persistence.rbの修正です。
touchメソッドに、任意の時刻を設定出来るようにする為のtimeオプションを追加しています。
user.touch(time: Time.new(2015, 2, 1, 0, 0, 0)) # UPDATE "users" SET "updated_at" = '2015-01-31 15:00:00' WHERE "users"."id" = ? [["id", 4]]
Track Gemfile.lock at the repository
.gitignore、.travis.ymlの修正です。バージョン管理にGemfile.lockを追加しています。
メインの理由は、bitsectをよりやりやすくする為で、テストが失敗した時、その時に使用していたgemの詳細(コミット番号等)がわかった方が調査がしやすいだろう、という事で追加したようです。バージョンだけならまだしも、コミット番号は確かに。
Revert "Merge pull request #18951 from jurezove/gemfile-lock-to-plugin-gitignore-template"
rails plugin用のgitignoreテンプレートにGemfile.lockを追加したコミットをrevertしています。
先のコミットであったように、エラー調査とうの事を考えると、Gemfile.lockはバージョン管理されてた方が良いのでは無いか、という事でrevertしています。
Talk about Gemfile.lock in the contributing guide
rails guideのContributing to Ruby on Railsの修正です。
Gemfile.lockの取り扱いについての説明を追記しています。
Merge pull request #15700 from maurogeorge/guides-local_assigns
actionview/lib/action_view/template.rb、guides/source/layouts_and_rendering.mdの修正です。
local_assignsの使い方について、API doc、rails guideそれぞれに説明を追加しています。
Improve documentation of local_assigns
actionview/lib/action_view/template.rbのdocの修正です。
先のコミットで追加されたlocal_assignsのAPI docの改善(説明の追加、docの位置を適切な箇所に移動)を行っています。
Add nodoc to private constant [ci skip]
actionview/lib/action_view/template.rbの修正です。
private constantに:nodoc:を追加しています。
Merge pull request #18634 from morgoth/deprecate-some-errors-methods
activemodel/lib/active_model/errors.rbの修正です。
ActiveModel::Errors#get、ActiveModel::Errors#set、ActiveModel::Errors#[]=メソッドをdeprecateにしています。
今後は、errors.messagesを直接操作するように、との事です。
errors.messages[:foo] = "omg" errors.messages[:foo]
そもそもgetの挙動がおかしく、getの挙動を直すまでもなく、直接messagesを参照すればよいだろう、という事でdeprecateになったようです。
Merge pull request #18393 from y-yagi/fix_mailer
Mailer Generatorの修正です。
generatorでmailerを生成する際、_mailerサフィックスを自動で付与する 、という対応があったのですが、テスト用のファイルからサフィックスの削除の対応が漏れていたのと、viewにも"mailer"サフィックスが付与さされてなかったので、viewにも"mailer"サフィックスが付与されるよう修正しています。
Merge pull request #18411 from todd/extract_record_tag_helper
ActionView::Helpers::RecordTagHelper moduleを外部gem(record_tag_helper)に切り出しています。
RecordTagHelperで提供されていたメソッド(div_for、content_tag_for)を使用したい場合、別途record_tag_helper gemを追加する必要があります。
DHHのコメントを見る限り、RecordTagHelperは実験的に追加したものの、実際は使わなかったので、coreから出しちゃえ―という感じようです。
Merge pull request #18917 from lautis/non-string-csrf-token
actionpack/lib/action_controller/metal/request_forgery_protection.rbの修正です。
authenticity_tokenにString以外の値(Hash等)を指定した場合に、NoMethodErrorが起きてしまっていたのを修正しています。
例。
{"authenticity_token": {"foo": "bar"}}
valid_authenticity_token?メソッド内でBase64.strict_decode64を呼び出しており、そこでNoMethodErrorが起きてしまっていたので、rescueの対象にNoMethodErrorを追加し、対応しています。これは次のコミットでまた修正されています。
actionpack/lib/action_controller/metal/request_forgery_protection.rbの修正です。
valid_authenticity_token?メソッドの第二引数のencoded_masked_tokenがStringクラスでがどうかメソッドの先頭でチェックし、Stringでない場合、直ぐreturn falseするよう修正しています。
Base64.strict_decode64メソッドの例外処理で、NoMethodErrorが起こらないようにするのようです。
Reduce the number of times #clean_path_info is called
actionpack/lib/action_dispatch/middleware/static.rbの修正です。
match?メソッドでclean_path_infoメソッドの呼び出し回数を減らすようリファクタリングしています。
+ path = Rack::Utils.clean_path_info path - paths = [path, "#{path}#{ext}", "#{path}/index#{ext}"].map { |v| - Rack::Utils.clean_path_info v - } + paths = [path, "#{path}#{ext}", "#{path}/index#{ext}"]
Freeze strings to reduce allocations in integration tests
actionpack/lib/action_dispatch/middleware/request_id.rbの修正です。
RequestIdクラス内で使用している文字列を凍結状態にしています。object allocations削減の為との事。
+ X_REQUEST_ID = "X-Request-Id".freeze # :nodoc: + ACTION_DISPATCH_REQUEST_ID = "action_dispatch.request_id".freeze # :nodoc: + HTTP_X_REQUEST_ID = "HTTP_X_REQUEST_ID".freeze # :nodoc: +
変更前の生成数が1030722で、変更後が967722との事。結構違いますねえ。
Allow Rack::Runtime to be deleted from middleware stack.
railties/lib/rails/configuration.rb`の修正です。
何かmiddlewareをdeleteした後に、その削除したmiddlewareをinsert_before、insert_afterメソッドに指定した場合に、No such middlewareエラーが発生するバグがあったのを修正しています。
Remove unused gsub_app_file method from Bukkit.
railties/test/isolation/abstract_unit.rbの修正です。
使用していないBukkit#gsub_app_fileメソッドを削除しています。
Should handle array option for :cast_as
activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rbの修正です。
配列型を使用している場合に、cast_asオプションの値が適用されないバグがあったのを修正しています。
Use delegate to call the methods to @conn
activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rbの修正です。
@connのメソッドを呼び出しているだけのメソッドについては、delegateメソッドを使用するよう修正しています。
Handle array option in type_to_sql
activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rbの修正です。
type_to_sqlメソッドの引数にarrayオプションを追加して、配列型を指定された場合の対応を追加しています。
Extract precision from datetime and time columns
activerecord/lib/active_record/connection_adapters/mysql_adapter.rb、
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rbの修正です。
datetime、timeカラムからprecisionオプションを取り除くよう修正しています。
Merge pull request #18910 from perceptec/add_suppressor
ActiveRecordの修正です。
save処理を発生させないようにする事が出来るActiveRecord::Suppressor moduleを新規に追加しています。
例えば、何かコメントを作成した場合に、そのコメントについての通知を送る、という処理があったとします。
class Comment < ActiveRecord::Base belongs_to :commentable, polymorphic: true after_create -> { Notification.create! comment: self, recipients: commentable.recipients } end
上記例のようにafter_create callbackでNotificationの作成を行う事により、コメントの作成時に必ず通知処理も作成される、という処理が行えます。
ただ、通常の場合は上記で問題無いのですが、イレギュラー処理(コメントのデータをコピーする、など)の場合に、Commentは作成するけど、Notificationは作りたく無い、という事があります。その場合に、今回コミットされた、ActiveRecord::Suppressorを使うと、Notificationの作成を抑制する事ができます。
module Copyable def copy_to(destination) Notification.suppress do # この間で`Comment`の作成処理が行われても、`Notification`の作成処理は行われない end end end
これは割と使いそう。
Copy edit the suppressor documentation
ActiveRecord::Suppressor 関連のdocの整理(スペースの追加、:nodoc:の追加等)を行っています。
Return true instead of self when suppressed
activerecord/lib/active_record/suppressor.rbの修正です。
save!処理を抑止した際に、trueを返すよう修正しています。
Do not mutate the operations array
railties/lib/rails/configuration.rbの修正です。
merge_infoメソッドで、配列の結合にconcatメソッドを使用していたのを、+を使用するよう修正しています。concatだとレシーバー自身を変更してしまう為。
Deprecate ActiveModel::Errors add_on_empty and add_on_blank methods
activemodel/lib/active_model/errors.rbの修正です。
ActiveModel::Errors#add_on_empty、ActiveModel::Errors#add_on_blankをdeprecateにしています。
先にコミットされたActiveModel::Errors#get, ActiveModel::Errors#set ActiveModel::Errors#[]=がdeprecateになった為、こちらも合わせてdeprecateにしたようです。
Fix code sample for custom exception handler [ci skip]
rails guideのRails Internationalization (I18n) APIの修正です。
Using Different Exception Handlersの項で、exampleの中のエラークラス名に誤りがあったのを修正しています。