なるようになるブログ

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

rails commit log流し読み(2016/08/22)

2016/08/22分のコミットです。

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

actionpack/CHANGELOG.md


Merge pull request #26234 from y-yagi/remove_unnessary_session_store_setting

guides/bug_report_templates/action_controller_master.rbの修正です。

bug report用のテンプレートファイルからconfig.session_storeの設定を削除しています。

Setup default session store internally, no longer through an applicat… · rails/rails@e5a6f7eの対応により、Rails内部でsession storeのデフォルトにcookie_storeを使用するようになり、cookie_storeを使用する場合は明示的な宣言は不要になった為。


Merge pull request #23759 from maclover7/fix-23757

actioncable/lib/action_cable/channel/base.rbの修正です。

ActionCable::Channel::Base#processable_action?でsubscriptionがrejectされないかどうかチェックするよう修正しています。

        def processable_action?(action)
-          self.class.action_methods.include?(action.to_s)
+          self.class.action_methods.include?(action.to_s) unless subscription_rejected?
         end

subscriptionがrejectされて場合にactionが実行されるのを避ける為、との事です。


Merge pull request #26241 from scottyantipa/query-interface-docs

rails guideのActive Record Query Interfaceの修正です。

Retrieving Objects from the Databaseの項にあるfinder methodについて説明している箇所で、説明されているメソッドは全てActiveRecord::Relationを返す、というような説明になっていたのですが、実際はそうではない(findfirstActiveRecord::Relationを返さない)為、説明を修正しています。


Fix ActionDispatch::Http::URL docs [ci skip]

actionpack/lib/action_dispatch/http/url.rbのdocの修正です。

ActionDispatch::Http::URLの各メソッドのdocに、Rack::Requestを継承した独自クラスを使用するexampleが記載されていたのを、ActionDispatch::Requestを使用するよう修正しています。

-      #   class Request < Rack::Request
-      #     include ActionDispatch::Http::URL
-      #   end
-      #
-      #   req = Request.new 'HTTP_HOST' => 'example.com'
+      #   req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com'
       #   req.url # => "http://example.com"

ActionDispatch::RequestRack::Requestを継承しなくなっており、元のexampleではエラーになってしまう為、との事です。


Return 307 status instead of 301 when rerouting POST requests to SSL

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

GET及びHEAD以外のrequestをhttpsにリダイレクトする際に、http statusに301を使用していたのを、307を使用するよう修正しています。

def redirection_status(request)
  if request.get? || request.head?
    301 # Issue a permanent redirect via a GET request.
  else
    307 # Issue a fresh request redirect to preserve the HTTP method.
  end
end

301だと元のmethod何であれGET requestになってしまう為、元のmethodを保持したままリダイレクトするようにする為に、307を使用するようにしたとの事です。

# Before
POST http://example.com/articles (i.e. ArticlesContoller#create)
redirects to
GET https://example.com/articles (i.e. ArticlesContoller#index)

# After
POST http://example.com/articles (i.e. ArticlesContoller#create)
redirects to
POST https://example.com/articles (i.e. ArticlesContoller#create)

Change form of table name to plural in query example

rails guideのActive Record Query Interfaceの修正です。

Joining Tablesの項のjoinsメソッドのexampleのテーブル名をタイポしていたのを修正しています。