Closed ephracis closed 2 years ago
The error occurs if a controller or model is changed, but not if a view is changed.
Seems to be any .rb
file inside app/
directory triggers the error. So JavaScript, views, assets, etc. will not trigger the error. Outside of app/
the only file where I could trigger the error was in config/routes.rb
. Changes to any other files such as initializers or environments, will not trigger the error.
Thanks for reporting! While we find a good fix, does surrounding your code in a rescue Ambry::AmbryError
work?
Rails.application.reloader.to_prepare do
Merit::Badge.create!(id: 1, name: 'test')
rescue Ambry::AmbryError
end
We shouldn't reload that file.
I couldn't replicate this issue. In order to test it, on latest master
, I did:
cd test/dummy
rails server
# load a page
# apply edits to views
# reload page
# see no error
I did it with Rails.application.reloader.to_prepare do
block in test/dummy/config/initializers/merit.rb
and without it. How can I see this bug?
Hm, well that's both good and bad news. Good news it's not affecting everyone, bad that it is not easy to replicate and fix. I am not sure why this is affecting me, but I will try the solution in #362 this weekend and see if it resolves the issue.
Let me know how it went! :)
I cannot reproduce this anymore. One thing that has changed is that ruby got updated to 3.0 a few weeks ago (and a few gems but I don't think they are relevant).
While I could try to downgrade and dig further into this I would rather just keep on truckin'. So I will close this.
Glad it seems to working well now!
How to recreate the issue:
bin/rails server
Expected result:
Actual result:
The merit.rb file:
If the page is reloaded it works. The error only occurs once and then goes away.
The error occurs if a controller or model is changed, but not if a view is changed.
This is not an issue in production since the app is restarted every time a code change is uploaded. But it is a real nuisance during development since it means every single code change must be followed by one error before the app works fine.