{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/28538","repository_url":"https://api.github.com/repos/rails/rails","labels_url":"https://api.github.com/repos/rails/rails/issues/28538/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/28538/comments","events_url":"https://api.github.com/repos/rails/rails/issues/28538/events","html_url":"https://github.com/rails/rails/pull/28538","id":216256537,"number":28538,"title":"Give clients a way to refer to ActionDispatch middleware classes without triggering an early load of ActionDispatch","user":{"login":"betesh","id":2154282,"avatar_url":"https://avatars2.githubusercontent.com/u/2154282?v=3","gravatar_id":"","url":"https://api.github.com/users/betesh","html_url":"https://github.com/betesh","followers_url":"https://api.github.com/users/betesh/followers","following_url":"https://api.github.com/users/betesh/following{/other_user}","gists_url":"https://api.github.com/users/betesh/gists{/gist_id}","starred_url":"https://api.github.com/users/betesh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/betesh/subscriptions","organizations_url":"https://api.github.com/users/betesh/orgs","repos_url":"https://api.github.com/users/betesh/repos","events_url":"https://api.github.com/users/betesh/events{/privacy}","received_events_url":"https://api.github.com/users/betesh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"matthewd","id":1034,"avatar_url":"https://avatars2.githubusercontent.com/u/1034?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewd","html_url":"https://github.com/matthewd","followers_url":"https://api.github.com/users/matthewd/followers","following_url":"https://api.github.com/users/matthewd/following{/other_user}","gists_url":"https://api.github.com/users/matthewd/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewd/subscriptions","organizations_url":"https://api.github.com/users/matthewd/orgs","repos_url":"https://api.github.com/users/matthewd/repos","events_url":"https://api.github.com/users/matthewd/events{/privacy}","received_events_url":"https://api.github.com/users/matthewd/received_events","type":"User","site_admin":false},"assignees":[{"login":"matthewd","id":1034,"avatar_url":"https://avatars2.githubusercontent.com/u/1034?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewd","html_url":"https://github.com/matthewd","followers_url":"https://api.github.com/users/matthewd/followers","following_url":"https://api.github.com/users/matthewd/following{/other_user}","gists_url":"https://api.github.com/users/matthewd/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewd/subscriptions","organizations_url":"https://api.github.com/users/matthewd/orgs","repos_url":"https://api.github.com/users/matthewd/repos","events_url":"https://api.github.com/users/matthewd/events{/privacy}","received_events_url":"https://api.github.com/users/matthewd/received_events","type":"User","site_admin":false}],"milestone":null,"comments":9,"created_at":"2017-03-23T01:11:14Z","updated_at":"2017-03-23T02:54:49Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/28538","html_url":"https://github.com/rails/rails/pull/28538","diff_url":"https://github.com/rails/rails/pull/28538.diff","patch_url":"https://github.com/rails/rails/pull/28538.patch"},"body":"### Summary\r\n\r\nThere is a bug in web-console, which is that it forces a load of ActionDispatch, and therefore ActionView, before all initializers have run.\r\n\r\nThe reason is because it needs to prepend its own middleware using `insert_before ActionDispatch::DebugExceptions` [here](https://github.com/rails/web-console/blob/v3.4.0/lib/web_console/railtie.rb#L36).\r\n\r\nHistorically, the workaround would have been to refer to `ActionDispatch::DebugExceptions` there using a String instead of the class, so that it's not eager-loaded.  However, that was deprecated in 83b767cef90abfc4c2ee9f4b451b0215501fae9a and is no longer supported as of 1b975e6a696655f476b10a4567b537cc92077563.\r\n\r\nThis commit resolves that, and enables us to fix web-console by making the following change (and I have a PR in progress for web-console, though I have not opened a ticket there yet):\r\n\r\n```\r\n# before\r\ninitializer 'web_console.insert_middleware' do |app|\r\n  app.middleware.insert_before ActionDispatch::DebugExceptions, Middleware\r\nend\r\n\r\n# after\r\ninitializer 'web_console.insert_middleware' do |app|\r\n  ActiveSupport.on_load(:action_dispatch_middleware) do\r\n    app.middleware.insert_before ActionDispatch::DebugExceptions, Middleware\r\n  end\r\nend\r\n```\r\n\r\nThis postpones the autoload of ActionDispatch until the latest possible moment, as the middleware stack is built.\r\n\r\n### Other Information\r\n\r\nPlease give me some guidance about what docs and CHANGELOGs to update.\r\n\r\n### How to reproduce\r\n\r\n1. Generate a fresh rails app\r\n2. Add the following to `config/initializers/action_view.rb`\r\n\r\n```\r\nRails.application.configure do\r\n  config.action_view.debug_missing_translation = false\r\nend\r\n```\r\n\r\n3. Run `bin/rails console` and enter the following:\r\n```\r\nActionView::Base.debug_missing_translation\r\n```\r\n\r\nNotice that it is set to true.\r\n\r\n4. Comment out web-console in the Gemfile, bundle install, and run the same command in the console.  This time, it is set to false as expected.\r\n"},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/288602826","html_url":"https://github.com/rails/rails/pull/28538#issuecomment-288602826","issue_url":"https://api.github.com/repos/rails/rails/issues/28538","id":288602826,"user":{"login":"matthewd","id":1034,"avatar_url":"https://avatars2.githubusercontent.com/u/1034?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewd","html_url":"https://github.com/matthewd","followers_url":"https://api.github.com/users/matthewd/followers","following_url":"https://api.github.com/users/matthewd/following{/other_user}","gists_url":"https://api.github.com/users/matthewd/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewd/subscriptions","organizations_url":"https://api.github.com/users/matthewd/orgs","repos_url":"https://api.github.com/users/matthewd/repos","events_url":"https://api.github.com/users/matthewd/events{/privacy}","received_events_url":"https://api.github.com/users/matthewd/received_events","type":"User","site_admin":false},"created_at":"2017-03-23T02:54:49Z","updated_at":"2017-03-23T02:54:49Z","body":"@rafaelfranca that does seem to impose awkward restrictions on what a 3rd party middleware can load (i.e., they would also have to avoid doing what DebugExceptions currently does).\r\n\r\nOTOH, I guess that's true either way. And your proposed path does mean *applications* can freely configure middleware without worrying about this."}}
{"actor":{"display_login":"matthewd"}}