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
Model does not reload #465
Comments
|
I just want to say thank you for an excellent bug report. I don't have time to check this out immediately, but this is very helpful. |
|
+1. For the way the bug report was done. I don't know about the bug itself. Cheers! |
|
Hi. I've checked this issue with mysql. You can check it from Issue is not just draper+pg related, with mysql I have the same results. |
|
I believe we're experiencing the same bug. Here are few side-effects (for those who google):
|
|
@sidonath |
|
@haines yes indeed, I meant Sorry about the confusion. |
|
I've been looking into this, thanks heaps for an awesome bug report @cr0t!! It doesn't seem to be ActiveRecord-related, so it's not dependent on the database: my fork demonstrates this. It seems to be purely related to Rails' code reloading. Basically, it seems to comes down to whether the model is referenced before the decorator:
Why the model is not reloaded in the former situation is beyond me, but I'll keep digging! |
|
Here's the problem (line 005): If you reference the model before the decorator, it removes it before the decorator. Then when it removes the decorator, it reloads the model for some reason. Because it's no longer in If you reference the decorator first, it removes it before the model, and the model is then unloaded successfully. Haven't worked out why it does this yet, but getting closer... |
|
Aha, found it... Rails checks if the class being unloaded responds to Should be an easy fix! |
Hello.
I found a strange bug with Draper gem and latest Rails (3.2.11) - I didn't check other Rails versions, but they might be buggy, too.
Weird behavior
If I decorate a model once in my code, than after second request model source code does not reload till reloading of full rails application (CTRL+C in case of running
rails s).I am sure that this is Draper gem problem (it can be related to pg), because when I do not use
decoratemethod everything goes fine. I created a test app to check it.How to reproduce
Please clone this repo https://github.com/cr0t/weird-draper-test
Bundle gems, initialize database, migrate and seed it. Then start the server and open
http://localhost:3000.Open two files in editor:
app/models/project.rbapp/views/welcome/index.html.erbThen change calling method
test_onetotest_two(for example... trick is in change method name, or add a new method) in the view file and update Project model method name too.Reload page in the browser. Everything is fine.
Do the same things one more time (change method name to new version in both places,
test_three, for example).Reload page. Oh! Crap! NoMethodError!
Screenshot: http://d.pr/i/7VLq
The text was updated successfully, but these errors were encountered: