Rails monkey patch initializer
By default in production we attempt to set the authorization mode to :whitelist meaning that end user will only be able to see requests where somewhere Rack::MiniProfiler.
Various aspects of rack-mini-profiler's behavior can be configured when your app boots. This probably won't ever break your application, but it can cause some unexpected behavior.
For example, in a Rails app, calls to stale? MemoryStore is the default otherwise. MemoryStore stores results in a processes heap - something that does not work well in a multi process environment.
FileStore stores results in the file system - something that may not work well in a multi machine environment. MiniProfiler will attempt to keep all user results isolated, out-of-the-box the user provider uses the ip address:. You can override something that is very important in a multi-machine production setup :. The string this function returns should be unique for each user on the system for anonymous you may need to fall back to ip address.
You can increase the granularity of profiling by measuring the performance of specific methods. Add methods of interest to an initializer.
It is also possible to profile any arbitrary block of code by passing a block to Rack::MiniProfiler. Single page applications built using Ember, Angular or other frameworks need some special care, as routes often change without a full page load.
Connect and share knowledge within a single location that is structured and easy to search. I am trying to monkey patch controller classes in a third party gem.
To be precise, I am trying to add parameter wrapping to devise controllers. It works great when the application starts, but when I modify one of my controller classes, the parameter wrapping stops working immediately.
As if the controller class was reloaded without the above patch. I had a similar issue before with trying to monkeypatch code that is lazy loaded in rails. I was able to fix it by wrapping my patch in a module then extending the module in the class you are editing. I may have a devise class name wrong, it should match whatever you are trying to monkeypatch. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?
Collectives on Stack Overflow. Already have an account? Sign in to comment. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Note that all users will beed to login again since both the remember me cookie and the session cookies.
Note also that the remember me cookie is tested multiple times per request even when it fails. Rails 4 not tested on Rails 3. This post was originally published on my blog. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
John Selawsky - Sep 9 ' Josh Blengino - Sep 8 ' Lee Wynne - Sep 7 ' Brandon Weaver - Sep 7 '
0コメント