New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
to_prepare not called on every development request #7152
Comments
I suspect your test case is failing because |
Yes, if |
@piglop any more info to help us on that? Otherwise we'll consider this closed, thanks! |
@carlosantoniodasilva I meet the same problem. I am in development mode, so
to test whether it reloads on every request, but it only executes when I start the rails server, after that, it never executes again |
the guide description is wrong, the behavior is keep consistent to load once in my testing project. |
It's not that the guide description is wrong, it does reload on every request in development, but it's tied to the classes reloader: if you don't change anything that's reloadable, ie a model, controller, view, route, or similar, it won't be triggered. If you do change anything under app/, or your routes, then I have to check with @josevalim and see if and how we're going to change the docs, but that's how it works since 3.2. |
Also important to link the related commit: fa1d9a8. See the commit description there for more info, and note that you can set |
Yes, we need to fix the docs. to_prepare is called every time your project is reloaded, which since Rails 3.2 means every time you change a file. |
Was the documentation fixed? I think it still has the error. |
`ActionDispatch::Callbacks.to_prepare` was deprecated in d3c9d80. In addition, `to_prepare` events does not call every request. `to_prepare` events call every time application is reloaded. Ref: rails#7152
Bump - this is still incorrect in Rails docs... yeeeeeears later |
@y-yagi any reason why your fix (y-yagi@5fb9cf1) wasn't merged? |
Hmm. Sorry, I couldn't remember why I didn't create a PR. If anyone interested to improve a doc, feel free to create a PR. |
Like in this stackoverflow question, my
to_prepare
block is called only once in development.The Rails guide says it should be called before every request in development. Is the guide wrong?
I illustrated the issue here: ouvrages@8841e2a based on 3-2-stable. The output is
<2> expected but was <1>
The text was updated successfully, but these errors were encountered: