2015/01/22分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
activemodel/CHANGELOG.md
- Support
:assignsoption when rendering with controllers/mailers. - Add ActionController::Renderer
- Add ActionController::Base.render
Fix test case class in the testing guide [ci skip]
rails guideのA Guide to Testing Rails Applicationsの修正です。
ActiveJobについて説明している箇所で、exampleのテストの親クラスがActiveSupport::TestCaseになっていたのを、ActiveJob::TestCaseに修正しています。
Replace if exists with table_exists? and drop table statement with drop_table
activerecord/test/cases/migration/references_foreign_key_test.rb、
activerecord/test/cases/primary_keys_test.rbの修正です。
drop table if existsを使用していた箇所をtable_exists?メソッドでテーブルのチェックをするよう修正しています。
Oracleではdrop table if existsが使用出来ない為修正しています。
Merge pull request #18322 from morgoth/add-error-codes
activemodel/lib/active_model/errors.rbの修正です。
エラーが起きたvalidatorのtypeを取得出来るActiveModel::Errors#detailsを追加しています。
class User < ActiveRecord::Base validates :name, presence: true end
user = User.new; user.valid?; user.errors.details # => {name: [{error: :blank}]}
複数エラーが起きても取得出来るようです。
class User < ActiveRecord::Base validates :name, presence: true validates :name, length: 1..30 end
user = User.new; user.valid?; user.errors.details => {:name=>[{:error=>:blank}, {:error=>:too_short, :count=>1}]}
Don't error when invalid json is assigned to a JSON column
activerecord/lib/active_record/connection_adapters/postgresql/oid/json.rbの修正です。
JSON型のカラムにJSONとして不正な値を設定した場合に、JSON::ParserErrorが起きていたのを、エラーをrescueしてnilを設定するよう修正しています。
Add ActionController::Metal#set_request!
ここからコントローラのセットアップを簡略化するための対応のコミットが続きます。
まずはactionpack/lib/action_controller/metal.rbの修正です。
ActionController::Metal#set_request!メソッドを追加しています。
calling dispatch無しでコントローラのインスタンスにrequestを設定する為のメソッドです。
Support :assigns option when rendering with controllers/mailers.
actionview/lib/action_view/rendering.rbの修正です。
_render_templateメソッドに:assignsオプションを追加しています。
render inline: '<%= @hello %>', assigns: { hello: "world" }
こんな使い方が出来るとの事。
Add ActionController#build_with_env
actionpack/lib/action_controller/metal/rack_delegation.rbの修正です。
custom envで簡単にコントローラのインスタンスが生成出来るActionController#build_with_envメソッドを追加しています。
Add ActionController::Renderer
コントローラアクション以外の箇所で任意のテンプレートをrenderする為のActionController::Rendererクラスを新規に作成しています。
以下のようなフォーマットで使えます。
FooController.render :action, locals: { ... }, assigns: { ... }
Add ActionController::Base.render
actionpack/lib/action_controller/metal/rendering.rbの修正です。
rendererにアクセスする為のActionController::Base.renderメソッドを追加しています。
Add ApplicationController.renderer initializer [ci skip]
railties/lib/rails/generators/rails/app/templates/config/initializers/application_controller_renderer.rbを新規に作成しています。
rendererのdefaults設定を記載する為のファイルで、サンプルは以下のような感じ。
## Change renderer defaults here. # # ApplicationController.renderer.defaults.merge!( # http_host: 'example.org', # https: false # )
ここでコントローラのセットアップを簡略化するための対応はおしまい。
use two spaces instead of one for include root in json
railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.ttの修正です。
exampleとして記載されているinclude_root_in_jsonオプションのスペースが1つだったのを、他のオプションと合わせて2つに修正しています。
railties/lib/rails/application/configuration.rb、
railties/lib/rails/engine.rbの修正です。
assetsをRailsのconfigurationから削除しています。
sprockets-railsの方で設定出来るようにした為、Rails本体からは削除したとの事です。
Add :formats to options list of render documentation.
rails guideのLayouts and Rendering in Railsの修正です。
renderメソッドの:formatsオプションについての説明を追加しています。
Disable builds AR-JDBC against master
.travis.ymlの修正です。
JRubyのmasterブランチでactiverecord-jdbc-adapterを使用するのを無効化しています。
activerecord-jdbc-adapterがmasterブランチでビルド失敗するとの事です。詳細はこちら。
fix regexp for validate an integer in guides [ci skip]
rails guideのActive Record Validationsの修正です。
intgerチェック用の正規表現に誤りがあったのを修正しています。