なるようになるブログ

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

rails commit log流し読み(2014/08/15)

2014/08/15分のコミットです。

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


Warm up Symbols with where method

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

DBのwarm upの為に、Post.firstを行っていたのですが、どうもこれだと不完全だったらしく、Post.where("author_id" => nil)に修正しています。

むう。何で駄目なんだろう。


Use string for order argument, fixed from #16501 [ci skip]

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

サンプルでorderメソッドの引数にSymbolを使用していたのをStringに修正しています。


Be sure to reset PK name renamed in the test

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

テストの中でカラム名を変更しているのですが、それを戻す処理が無かった為、ensureを追加し、戻す処理を入れています。


extract methods and metaprogram less.

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

polymorphic_urlpolymorphic_actionを生成する処理をメソッドに切り出しています。


Ignore MySQL "SHOW VARIABLES" when counting queries

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

出力されるQueryのテストを行う際、SHOW VARIABLESQueryについて無視するよう対応しています。


Perf optimization for url_for called w/ Hash

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

url_forメソッドの性能改善を行っています。

-        super({ :only_path => options[:host].nil? }.merge!(options.symbolize_keys))
+        options = options.symbolize_keys
+        options[:only_path] = options[:host].nil? unless options.key?(:only_path)
+        super(options)

merge!が無くなったので、Hashの生成処理が抑えられた感じですかねえ。

結果は以下の通りです。

Calculating -------------------------------------
     Default without     10903 i/100ms
       turbo without     12170 i/100ms
-------------------------------------------------
     Default without   194479.4 (±22.0%) i/s -     915852 in   5.002688s
       turbo without   218647.1 (±19.4%) i/s -    1046620 in   5.010165s

Comparison:
       turbo without:   218647.1 i/s
     Default without:   194479.4 i/s - 1.12x slower

Calculating -------------------------------------
       Default with      10473 i/100ms
         turbo with      12073 i/100ms
-------------------------------------------------
       Default with    167402.4 (±21.2%) i/s -     795948 in   5.026266s
         turbo with    209947.7 (±20.4%) i/s -    1002059 in   5.022797s

Comparison:
         turbo with :   209947.7 i/s
       Default with :   167402.4 i/s - 1.25x slower

1.25x、というのは凄いですねえ。


Spelling errors

各docの修正です。スペルミスの修正のみです。


s/Dont'/Don't/

railties/lib/rails/generators/rails/controller/controller_generator.rbのdocの修正です。

Dont'をDon't`に修正。スペルミス、というかタイポですね。


create_table + transactional_fixtures = :bomb:

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

ActiveRecord::SchemaMigration.create_tableuse_transactional_fixturesを同時に使ってしまっている箇所があったのを修正しています。


Use the method for determining attribute methods rather than duplicating

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

カラムの存在チェックを少しリファクタリングしています。

-          if attributes.key?(column.to_s) && self.send(column).nil?
-            write_attribute(column.to_s, current_time)
+          column = column.to_s
+          if has_attribute?(column) && !attribute_present?(column)

より適切なメソッドを使用するように、という事ですね。


prefer has_attribute? over attributes.key?.

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

attributes.key?を使用するより、has_attribute?を使用した方がよい、という事でテストを修正しています。


fix typo in method name (broken build :sweat:)

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

先ほどの修正でメソッド名をタイポしてしまったので、再度修正しています。


Fixed link for in_place_editor [ci skip]

rails guideのRuby on Rails Security Guideの修正です。

in_place_editingのリンクが誤っていたのを修正しています。


Point to rubygems instead of Rails GitHub. [ci skip]

もう一回rails guideのRuby on Rails Security Guideの修正です。

先ほどの修正で、in_place_editingのリンクをhttps://github.com/rails/in_place_editingに修正したのですが、ここも適切なリンクでは内、という事で、https://rubygems.org/gems/in_place_editingに再度修正しています。