2015/06/27分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Improve detection of partial templates eligible for collection caching, now allowing multi-line comments at the beginning of the template file.
- Add reversible syntax for change_column_default
Add reversible syntax for change_column_default
ActiveRecordの修正です。
change_column_default
メソッドに、リバーシブルに使用出来るようにする為の、from
、to
オプションを追加しています。
例。
change_column_default :posts, :status, from: nil, to: "draft" change_column_default :users, authorized, from: true, to: false
Update guide for new change_column_default syntax
rails guideのActive Record Migrations
の修正です。
change_column_default
メソッドについて説明している箇所に、from
、to
オプションについての説明を追加しています。
Update .pluck documentation on uniq
activerecord/lib/active_record/relation/calculations.rb
のdocの修正です。
pluck
メソッドのdocで、DISTINCT
をするのに直接DISTINCT
クエリーを使用していたのを、uniq
メソッドを使用するよう修正しています。
- # Person.pluck('DISTINCT role') + # Person.uniq.pluck(:role)
カラム名を明確に指定する必要がない分簡単に使えるだろう、との事で修正したようです。
Merge pull request #20417 from dubek/fix-template-cache-call-pattern
actionview/lib/action_view/template/handlers/erb.rb
の修正です。
collection cachingマッチ用の正規表現を修正し、cache
の前に複数行のコメントを書いても正しくキャッシュされるよう修正しています。
<%# comment 1 %> <%# comment 2 %> <% cache customer do %> # ... <% end %>
上記のような処理でも、正しくキャッシュされるようになっています。
Change routes.rb look in getting started [ci skip]
rails guideのGetting Started with Rails
の修正です。
Setting the Application Home Page
の項に記載されているconfig/routes.rb
の内容が、実際の内容と異なっていたのを修正しています。
correct file_fixture_path
in plugins test_helper.rb
railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb
の修正です。
plugin内のtest_helper.rb
のfile_fixture_path
の値に、/
が不足していたのを追加しています。
Merge pull request #20699 from vngrs/foreign_key_with_table_name_suffix_and_prefix
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
、
activerecord/lib/active_record/migration.rb
の修正です。
foreign key機能に、テーブル名サフィックス/プレフィックスサポートを追加しています。
テーブル同様、ActiveRecord::Base.table_name_prefix
、ActiveRecord::Base.table_name_suffix
に指定した値を参照するようになっています。
# migration def change create_table(:schools) create_table(:classes) do |t| t.column :school_id, :integer end add_foreign_key :classes, :schools end
ActiveRecord::Base.table_name_prefix = 'p_' migration = CreateSchoolsAndClassesMigration.new migration.migrate(:up) #=> `p_classes` という名前で外部キーが作成される
Merge pull request #20607 from cmtonkinson/update-console-colors
activerecord/lib/active_record/log_subscriber.rb
の修正です。
sql queryをコンソールに表示さる際の、色の設定を修正しています。
query 毎に色分け(insert
は緑、select
は青、という具合) するようになっています。
- if odd? - name = color(name, CYAN, true) - sql = color(sql, nil, true) - else - name = color(name, MAGENTA, true) - end + name = color(name, nil, true) + sql = color(sql, sql_color(sql), true) debug " #{name} #{sql}#{binds}" end - def odd? - @odd = !@odd + def sql_color(sql) + case sql + when /\s*\Ainsert/i then GREEN + when /\s*\Aselect/i then BLUE + when /\s*\Aupdate/i then YELLOW + when /\s*\Adelete/i then RED + when /transaction\s*\Z/i then CYAN + else MAGENTA + end
イメージは以下の通り。
Remove config
options from default_options
in railties
railties/lib/rails/commands/server.rb
の修正です。
rails serverのデフォルトオプションからconfig
を削除しています。
File.expand_path
がrackとrailsでそれぞれ呼ばれてしまっているので、片方削除出来るのでは、というissue(Remove of File.expand_path in Rails::Server · Issue #20345 · rails/rails)があって、その対応、との事なのですが、何故かconfig
オプション自体が削除されてしまっています。うーん、これ良いのかなあ。
Merge pull request #20652 from ankit1910/change_doc
rails guideのActive Record Associations
の修正です。
collection.build 及び collection.create メソッドについてのdocについて、グラマーの修正、及びexampleの追加を行っています。
Improve Validation Helpers' documentation comments and tests
ActiveModelの修正です。
各validation methodのdocの説目が不足していたのをあったのを追加、及び不足していたテストを追加しています。