当前位置:网站首页>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边栏推荐
- @The problem of cross database query invalidation caused by transactional annotation
- [brush questions] BFS topic selection
- Behavior perception system
- Mixed compilation of C and CC
- 阿里云ECS使用cloudfs4oss挂载OSS
- About the prompt loading after appscan is opened: guilogic, it keeps loading and gets stuck. My personal solution. (it may be the first solution available in the whole network at present)
- Moco is not suitable for target detection? MsrA proposes object level comparative learning target detection pre training method SOCO! Performance SOTA! (NeurIPS 2021)...
- 【虚幻引擎UE】实现背景模糊下近景旋转操作物体的方法及踩坑记录
- NetSetMan pro (IP fast switching tool) official Chinese version v5.1.0 | computer IP switching software download
- Pyqt pyside custom telescopic menu bar sharing (including tutorial)
猜你喜欢

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

快手、抖音、视频号交战内容付费

Rust区块琏开发——签名加密与私钥公钥
![[finebi] the process of making custom maps using finebi](/img/3a/d638dbac6a26c37087ec9550c35e63.png)
[finebi] the process of making custom maps using finebi

What is test development? Why do so many companies hire test developers now?

Interview related high-frequency algorithm test site 3

C language course setting: cinema ticket selling management system

laravel8 导出Excle文件

Use of vscode software

What is the reason why the webrtc protocol video cannot be played on the easycvr platform?
随机推荐
Threejs rendering obj+mtl model source code, 3D factory model
User behavior collection platform
After the deployment of web resources, the navigator cannot obtain the solution of mediadevices instance (navigator.mediadevices is undefined)
[phantom engine UE] the difference between running and starting, and the analysis of common problems
Uni app change the default component style
File upload bypass summary (upload labs 21 customs clearance tutorial attached)
3. Package the bottom navigation tabbar
Moco is not suitable for target detection? MsrA proposes object level comparative learning target detection pre training method SOCO! Performance SOTA! (NeurIPS 2021)...
CTF stegano practice stegano 9
Online text line fixed length fill tool
Use threejs to create geometry and add materials, lights, shadows, animations, and axes
我国算力规模排名全球第二:计算正向智算跨越
Online sql to excel (xls/xlsx) tool
如何优雅的获取每个分组的前几条数据
Pyqt5 displays file names and pictures
WGS84 coordinate system, web Mercator, gcj02 coordinate system, bd09 coordinate system - brief introduction to common coordinate systems
Ctfshow web entry code audit
陇原战“疫“2021网络安全大赛 Web EasyJaba
【虚幻引擎UE】实现UE5像素流部署仅需六步操作少走弯路!(4.26和4.27原理类似)
【虚幻引擎UE】运行和启动的区别,常见问题分析