なるようになるブログ

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

rails commit log流し読み(2014/11/26)

2014/11/26分のコミットです。

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

activerecord/CHANGELOG.md

actionview/CHANGELOG.md

railties/CHANGELOG.md


Fixing wrong link in 'Ruby on Rails 3.0 Release Notes' [ci skip]

guides/source/3_0_release_notes.mdの修正です。

Arelについての記事のリンクが誤っていたのを修正しています。


do not trigger AR lazy load hook before initializers ran.

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

rake_tasksの先頭で行なっていたactive_record/baseのrequire処理を削除しています。

active_record/baseのrequireを実行すると、active_record.set_configsのイニシャライズが直ぐ実行されてしまうのですが、先頭だとconfig/initializersの読み込み処理が終わっていない為、initializersで設定した値が反映されない、という問題があったので、修正したようです。


bring back db:test:prepare.

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

一旦deprecateになったdb:test:prepareタスクを、deprecateから戻しています。

理由としては、

  1. プラグインに、test databaseの初期化処理のフックポイントを提供する為 
  2. test用databaseを強制的にシンクする為の方法を提供する為

CSS fix for the router visualizer

actionpack/lib/action_dispatch/journey/visualizer/fsm.cssの修正です。

router visualizerのスタイルが崩れてしまうケースがあったのを修正しています。


Setting an association replaces records with the same id in memory

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

associationに同じIDの異なるインスタンスのレコードを設定した場合に、値が正しく置き換えられなかったバグがあったのを修正しています。

テストより。

bulb = Bulb.create!
car = Car.create!(bulbs: [bulb])

new_bulb = Bulb.find(bulb.id)
new_bulb.name = "foo"
car.bulbs = [new_bulb]

assert_equal "foo", car.bulbs.first.name

本来、最後のcar.builds.first.nameは途中で設定した"foo"になるはずですが、これは"foo"にならず、最初にbuldを作成した時の値のままになってしまっていたようです。


Remove Web Console /console references in the guides

guides/source/4_2_release_notes.mdguides/source/upgrading_ruby_on_rails.mdの修正です。

Web Consoleのterminalのマウント機能についての説明を削除しています。

web-consoleのissueによると、terminalのマウント機能は別gemとして切り出し、現在のWeb Consoleからは削除するようです。


Local vars should exist in partials for falsy :object: values too

actionview/lib/action_view/renderer/partial_renderer.rbの修正です。

partialに指定出来るobjectオプションの値がfalseの場合、値を渡さないよう修正しています。


Move PG float quoting to the correct location

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

Float型の場合のquote処理をquote_stringの中に移動しています。


Use released rails-dom-testing

gemspecの修正です。リリース済みのrails-dom-testingを使用するよう修正しています。


Use released arel

gemspecの修正です。リリース済みのarelを使用するよう修正しています。


Merge pull request #17733 from yuki24/do-not-rescue-exception-in-params-parser

actionpack/lib/action_dispatch/middleware/params_parser.rbの修正です。

parse_formatted_parametersメソッドExceptionをrescueいていたのを削除しています。

-      rescue Exception => e # JSON or Ruby code block errors
+      rescue => e # JSON or Ruby code block errors

NoMemoryError等が起きた場合もParseErrorエラーに丸められてしまっていたので、修正したようです。


Fix syntax error :bomb:

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

Gemfileの生成処理に箇所にタイポがあり、syntax errorがおきていたのを修正しています。


Generators add foreign keys on references

generatorの修正です。

generatorでreferencesオプションを使用した場合、マイグレーションにforeign keysを追加するよう修正しています。

bin/rails generate model account supplier:references
class CreateAccounts < ActiveRecord::Migration
  def change
    create_table :accounts do |t|
      t.references :supplier, index: true

      t.timestamps null: false
    end
    add_foreign_key :accounts, :suppliers
  end
end

Fix warning in AV tests

actionview/lib/action_view/renderer/partial_renderer.rbの修正です。

先に行ったpartialの対応で、rubyのwarningが出力されるようになってしまったので、処理を修正しています。


Use web_console 2.0 for 4.2.0.rc1 release

railties/lib/rails/generators/rails/app/templates/Gemfileの修正です。

web_consoleの2.0を使用するよう修正しています。


Merge pull request #17728 from jcutrell/jcutrell/docs-to_session_value-for-pr

actionpack/lib/action_dispatch/middleware/flash.rbのdocの修正です。

ActionDispatch::Flash::FlashHash#to_session_valueメソッドにdocを追加しています。


Use jquery-rails 4.0.0

Gemfilerailties/lib/rails/generators/app_base.rbの修正です。

jquery-railsの4.0を使用するよう修正しています。


Clarify where result goes, and supported formats of generate task.

guides/Rakefileのdocの修正です。

guides:generateタスクで生成されるdocのフォーマットについての説明を追加しています。


getting the location of the server

actionpack/lib/action_controller/base.rbのdocの修正です。

docにlocationを取得するexampleがあるのですが、その中でrequest.env["SERVER_ADDR"]の代わりに、request.env["REMOTE_ADDR"]を使用するよう修正しています。 そもそも、SERVER_ADDRのというkeyで値の取得は出来ないような。


:scissors:

actionpack/lib/action_controller/base.rbのdocの取得です。

不要な空行を削除しています。


Remove extra empty line

actionpack/lib/action_controller/log_subscriber.rbの修正です。

こちらも不要な空行を削除しています。


Active Record change log pass [skip ci]

activerecord/CHANGELOG.mdの修正です。

  • グラマーとスペルの修正
  • "PostgreSQL"に表記を統一
  • backticksの追加
  • 1行を80文字に抑えるよう修正

を行っています。


Use absolute_path of caller_locations to infer engine root

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

inheritedメソッドで、caller_locationsを取得する際、 pathではなくabsolute_pathの値を取得するよう修正しています。

-              caller_locations.map(&:path)
+              caller_locations.map(&:absolute_path)

pathだとファイル名しか取得出来ないので、フルパスで取得出来るように、ですかね。


Refactor nested if

actionpack/lib/action_dispatch/routing/mapper.rbの修正です。

appメソッドでネストしているifを減らすようリファクタリングしています。


Provide support for SQL Server connections with dbconsole using sqsh

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

dbconsoleで"sqlserver"が使用出来るよう対応を追加しています。

railssqlserver…。中々に辛そうな感じですが…。


Add #record attribute to RecordNotFound and RecordDestroyed exceptions.

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

RecordNotSavedRecordNotDestroyedクラスにrecordアトリビュートを追加しています。

これにより、上記エラーが発生した際、エラーが発生したレコードの情報を取得出来るようになりました。

begin
  complex_operation_that_internally_calls_destroy!
rescue ActiveRecord::RecordNotDestroyed => invalid
  puts invalid.record.errors
end

various error classes: added newlines & removed :nodoc: flag from public attribute.

activerecord/lib/active_record/errors.rbactiverecord/lib/active_record/validations.rbの修正です。

public APIからのnodocの削除、改行の追加等を行っています。


Merge pull request #17761 from pschrammel/master

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

PostgreSQLのadapterの判定式を修正しています。

-      when "postgresql", "postgres", "postgis"
+      when /^postgres|^postgis/