-
Notifications
You must be signed in to change notification settings - Fork 21.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using strings or symbols for middleware class names is deprecated.
Convert things like this: middleware.use "Foo::Bar" to this: middleware.use Foo::Bar
- Loading branch information
1 parent
435b224
commit 83b767c
Showing
6 changed files
with
61 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83b767c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just ran across a deprecation message in my app for this today and tried to follow the advice. Given the following:
app/middleware/client_searcher.rb
with classClientSearcher
application.rb
used to have:config.middleware.insert_before ActionDispatch::Cookies, "ClientSearcher"
config.middleware.insert_before ActionDispatch::Cookies, ClientSearcher
leads to aNameError: uninitialized constant
error.If I add
require_relative "../app/middleware/client_searcher"
to application.rb I am back to booting. Looking through the docs, I am not certain why I have to do this. Without the require_relative line, what should I have done differently to fix the deprecation warning?83b767c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I understood, Rails 3.2 introduced the support for
app/middleware
as the home for custom middleware and it would be auto loaded. Where in the docs for Rails 5 does it cover this change?83b767c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@memoht You may wanna do this in an initializer, as the autoloading code still haven't kicked in when you are referencing this constant in
config/application.rb
.83b767c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gsamokovarov I haven't done that before. What would I put in the initializer to load this custom middleware? I created GIST to show what I have in this file: https://gist.github.com/memoht/30781d733a85eab94d86213b48b09cf2
83b767c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
83b767c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @gsamokovarov . That worked. I appreciate your time.