I am playing with the console, I change some model code and now I want to test it. I normally re-start the console. Is there a quicker way? Maybe a console command to reload the model开发者_StackOverflow code?
Of course, simply type:
reload!
You need to call reload!
This command will clear the loaded constants that have been loaded and will load them as they're referenced in the console.
If you have old objects from before the reload!
you will need to call reload
on these individual objects or find new objects and work with them if you want to try out the new method.
You can type reload!
.
I think it's important to note that reload!
doesn't reinitialize rails console session existing objects, it just reloads the code:
https://stackoverflow.com/a/10465369/9185715
So, if you have instantiated any objects in the console, they won't be reinitialized.
精彩评论