当前位置:网站首页>How to force activerecord to reload a class- How do I force ActiveRecord to reload a class?
How to force activerecord to reload a class- How do I force ActiveRecord to reload a class?
2022-07-05 04:17:00 【French red wine sweet】
problem :
I'm creating a bunch of migrations, some of which are standard "create table" or "modify table" migrations, and some of which modify data. I am creating a series of migrations , Some of them are standard “ Create table ” or “ Modify table ” transfer , Some of these migrations modify data .I'm using my actual ActiveRecord models to modify the data, a la: I am using my actual ActiveRecord Model to modify data ,a:
Blog.all.each do |blog| update_some_blog_attributes_to_match_new_schemaend
The problem is that if I load the Blog class, then modify the table, then use the Blog class again, the models have the old table definitions, and cannot save to the new table. The problem is , If I load Blog class , Then modify the table , Then use it again Blog class , Model has old table definition , And cannot be saved to a new table .Is there a way to reload the classes and their attribute definitions so I can reuse them? Is there any way to reload classes and their attribute definitions , So that I can reuse them ?
Solution :
Reference resources : https://stackoom.com/en/question/qEv边栏推荐
- 蛇形矩阵
- [phantom engine UE] realize the animation production of mapping tripod deployment
- Sequence diagram of single sign on Certification Center
- 【虚幻引擎UE】打包报错出现!FindPin错误的解决办法
- open graph协议
- All in one 1413: determine base
- 小程序中实现文章的关注功能
- [illusory engine UE] method to realize close-range rotation of operating objects under fuzzy background and pit recording
- 机器学习 --- 决策树
- Machine learning decision tree
猜你喜欢
Threejs Internet of things, 3D visualization of farms (II)
MacBook installation postgresql+postgis
The new project Galaxy token just announced by coinlist is gal
【虚幻引擎UE】打包报错出现!FindPin错误的解决办法
NEW:Devart dotConnect ADO. NET
【虚幻引擎UE】实现测绘三脚架展开动画制作
How does the applet solve the rendering layer network layer error?
【thingsboard】替换首页logo的方法
Seven join join queries of MySQL
[phantom engine UE] realize the animation production of mapping tripod deployment
随机推荐
The order of LDS links
我国算力规模排名全球第二:计算正向智算跨越
Kwai, Tiktok, video number, battle content payment
American 5g open ran suffered another major setback, and its attempt to counter China's 5g technology has failed
[moteur illusoire UE] il ne faut que six étapes pour réaliser le déploiement du flux de pixels ue5 et éviter les détours! (4.26 et 4.27 principes similaires)
Online text line fixed length fill tool
[charging station]_ Secular wisdom_ Philosophical wisdom _
Machine learning -- neural network
网络安全-记录web漏洞修复
机器学习 --- 神经网络
Decimal to hexadecimal
ClickPaaS低代码平台
Threejs implements labels and displays labels with custom styles
EasyCVR平台出现WebRTC协议视频播放不了是什么原因?
[phantom engine UE] only six steps are needed to realize the deployment of ue5 pixel stream and avoid detours! (the principles of 4.26 and 4.27 are similar)
The new project Galaxy token just announced by coinlist is gal
【虚幻引擎UE】实现背景模糊下近景旋转操作物体的方法及踩坑记录
PR video clip (project packaging)
Network security - record web vulnerability fixes
What is test development? Why do so many companies hire test developers now?