How can I disable ActiveSupport::Notifications on Rails 7? - ruby-on-rails

I'm trying to upgrade my API from Rails 6 to Rails 7, and got this error after solving dependences and running my app:
Error:
ActiveSupport::Notifications::InstrumentationSubscriberError (Exception(s) occurred within instrumentation subscribers: NoMethodError, NoMethodError)
I never use this feature, searching all my files doesn't exist any mention to this Notifications.
Couldn't identify who and why is calling this notifications and neither find on Rails 7 Docs how can I disable this feature to solve my problem. Anyone know how can I do it?
Tried remove completely the ahoy_matey gem that appears in traceback and change de API mode to false on config/application.rb but both doesn't work.
I expect disabling this feature can fix my problem.

I was getting this exact same error, and the listed solution didn't work for me.
My specific error was an old version of the Airbrake notifier library (v10, updating the v13 fixed it), but to track it down I looked at the error page, which included the NoMethodError error traces below the main application trace.
So if this happens to you, hopefully you won't lose two days to it like I just have. 😬

after spend few hours searching the docs of rails 7, I finally found it. Right here, where it says:
Controls behavior when parameters that are not explicitly permitted are found. The default value is :log in test and development environments.
:log to emit an ActiveSupport::Notifications.instrument event on the unpermitted_parameters.action_controller topic and log at the DEBUG level
The solution was add config.action_controller.action_on_unpermitted_parameters = false on my config/application.rb file.

Related

Rails 7 Update Breaking in Production on Heroku

First post here, so bear with me...
I recently updated my Rails app to 7.0.1 (latest stable release) from 6.1.4. My test suite is still green and the deployment to Heroku succeeds. However, when trying to open the app I get the classic "We're sorry, but something went wrong message". Checking the logs, this is the output:
ErrorMessage1
ErrorMessage2
I'm still relatively new to Rails/Heroku deployments, and I'm stumped on where to look to try and fix this. The NoMethodError does not show many solutions online, any help is appreciated! Thank you in advance.
Your problem is related to an open issue about airbrake Discussion on rails repo Discussion on airbrake repo.
The issue is triggered when we use eager loading. For now, the quickest solution would be to disable eager loading and watch the issue or continue with rails 6 or temporarily stop using airbrake.
config.eager_load = false // to disable eager loading _ production.rb
[edit]
A new version of airbrake fixes this issue so that you won't need to disable eager loading in production. airbrake:13.0.0 fix.
So, you'll just need to update to the proper version in your Gemfile.

Rails 6 Action Mailbox internal route not working correctly

Having issues with Rails 6 Action Mailbox. I went through all the steps on the install and it appeared I had no issues with the setup. But when I navigate to localhost:3000/rails/conductor/action_mailbox/inbound_emails I get the following error:
undefined method `new_rails_conductor_inbound_email_path' for #
Setting config.api_only = false in application.rb fixed issue for me.
For anyone else following the ActionMailbox setup guide (I encountered the same issue). From what I can see, as of today (Tues Jan 7th 2020), Conductor has not yet made it into a Rails release. There is an active pull request with recent review activity, so I would guess the documentation is just a little ahead of the code.
https://github.com/rails/rails/pull/35489

How do I debug errors with ActiveAdmin with Ruby on Rails?

There is a rails application that uses bunch of gems one of which is ActiveAdmin.
Dashboard works OK, but other custom tabs gets a 500 response.
How do I enabled debugging/logging inside ActiveAdmin gem to get to the bottom of this problem?
Corresponding generic question is this: what are the ways to enable debugging on rails apps with multiple gem dependencies?
1) Check your development.log file after hitting the custom tab page and see where the error was. The log should give you a stack trace or at least tell you the last controller that was hit. You can use this information to work backwards and find out where you code is breaking.
2) Once you have found the broken spot in the code you can use raise or pry debugger to inspect variables/methods to help you debug.
This turned out to be a version mismatch between the mongoid interface and the active admin interface.Thanks for all the help.

How can I configure Rails to raise an error when it hits a deprecation warning?

I'm upgrading a rather large app from Rails 3.0 to 3.2, and trying to get rid of all the deprecation warnings. My question isn't what to change to resolve particular warnings, but how to get Rails to treat them like exceptions so it will dump a stack trace in dev mode, so I'll have the full stack trace to see where the offending code is coming from. That way I can just use my test suite to find them all, and verify that they're all cleaned up. If there's a way to get rspec to fail a test if it logs a deprecation warning, that would work as well.
(In case anyone wonders, the reason I'm not upgrading all the way to rails 4.0 is that the app depends on some gems that AFAIK aren't fully ready for rails 4 yet, especially activerecord-oracle_enhanced-adapter.)
In Rails 4 you can configure using
config.active_support.deprecation = :raise
in your test.rb or development.rb file.
Other available methods can be found in ActiveSupport::Deprecation::Behaviour
The deprecation warning is handled by ActiveSupport::Deprecation, when some code want to show such warning, it calls
ActiveSupport::Deprecation.warn("some message")
There is no error thrown. To answer your question, I'm afraid you have to use dark tool of monkey patching :) Anyway the solution is for temp usage and will get removed later.
Update:
OP pointed out a quick and legit method in comment, so monkey patching is no longer a choice.
Here is his code:
# config/environments/test.rb
ActiveSupport::Deprecation.debug = true

rails 3.2 development mode is not displaying the full error page with backtrace etc

I just upgraded to rails 3.2 Everything is working fine except error pages no longer show the normal development debug info. Instead it's showing the standard production error page (white background with red text in the middle:
"We're sorry, but something went wrong. We've been notified about this issue and we'll take a look at it shortly."
Is there a new setting or something I'm missing for rails 3.2? I've read over the upgrade instructions and do not see it mentioned anywhere. I tried downgrading to 3.1.3 and the error pages work again so this is definitely a rails 3.2 issue. Thanks.
Check the config.consider_all_requests_local inside development.rb. It must be set to true in order to show full error reports.
Nicolas, I'm faced the same problem and only saw the message We're sorry, but something went wrong. and nothing in logs.
The problem was in UTF-8 characters, so adding encoding declaration to the beginning of the file solved it:
# encoding = utf-8
If neither jibiels nor Dmitrys solution helped, try out the solution mentioned here:
Rails doesnt log tempalte errors in development mode
(Maybe this also helps you, #Nicolas)

Resources