当前位置:网站首页>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_schemaendThe 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边栏推荐
- laravel8 导出Excle文件
- 在线文本行固定长度填充工具
- 【虚幻引擎UE】打包报错出现!FindPin错误的解决办法
- Why can't all browsers on my computer open web pages
- A應用喚醒B應該快速方法
- How to get the first few pieces of data of each group gracefully
- Open graph protocol
- Phpmailer reported an error: SMTP error: failed to connect to server: (0)
- MacBook installation postgresql+postgis
- Rome chain analysis
猜你喜欢

NEW:Devart dotConnect ADO. NET

【虚幻引擎UE】实现背景模糊下近景旋转操作物体的方法及踩坑记录

EasyCVR平台出现WebRTC协议视频播放不了是什么原因?
![[phantom engine UE] realize the animation production of mapping tripod deployment](/img/89/351641c3da7e2acdbf389bc298b75e.png)
[phantom engine UE] realize the animation production of mapping tripod deployment

C language course setting: cinema ticket selling management system

Why do big companies such as Baidu and Alibaba prefer to spend 25K to recruit fresh students rather than raise wages by 5K to retain old employees?

American 5g open ran suffered another major setback, and its attempt to counter China's 5g technology has failed

行为感知系统

mxnet导入报各种libcudart*.so、 libcuda*.so找不到

陇原战“疫“2021网络安全大赛 Web EasyJaba
随机推荐
【FineBI】使用FineBI制作自定义地图过程
How to realize real-time audio and video chat function
Rome链分析
如何实现实时音视频聊天功能
Three level linkage demo of uniapp uview u-picker components
PR video clip (project packaging)
Rome chain analysis
[understand series after reading] 6000 words teach you to realize interface automation from 0 to 1
Serpentine matrix
[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)
Clickpaas low code platform
Rust区块琏开发——签名加密与私钥公钥
25K 入职腾讯的那天,我特么哭了
快手、抖音、视频号交战内容付费
【UNIAPP】系统热更新实现思路
Possible stack order of stack order with length n
【虚幻引擎UE】打包报错出现!FindPin错误的解决办法
SPI read / write flash principle + complete code
长度为n的入栈顺序的可能出栈顺序种数
Pyqt5 displays file names and pictures