in the sample below:
class BookLib < ActiveRecord::Base
self.abstract_class = true
end
since abstract_class is set to true, this model class shifts to be a fade one(no table will be create for it), why we need a fade model in our project? yeah , we do need, it's powerful air in some cases.
let's assume a situation: we gonna request a batches data of book, the problem is these data were stored into another independent db. so how we touch them in our project.
let's do it like these:
class BookLib < ActiveRecord::Base
self.abstract_class = true
establish_connection("db_#{RAILS_ENV}".to_sym)
validates_presence_of :name
end
class BookTag < BookLib; end
class Book < BookLib; end
in these way, when we gonna CRUD booktag and book , the project will establish connection first.
分享到:
相关推荐
where_and_why_to_use_event_processing_platforms
信息安全_数据安全_Frameworks and Why We Use Them 风险分析 移动安全 漏洞管理 安全测试 AI
2013春人教版七年级下英语unit_5_Why_do_you_like_pandas_?Section_A
The_Power_of_Cooperation_Why_Cybersecurity_Risks_Need_Public_Private_Punch 威胁情报 安全运营 渗透测试 威胁情报 业务安全
A pioneer of artificial intelligence shows how the study of causality ... And just as Pearl's discoveries have enabled machines to think better, The Book of Why explains how we can think better.
七年级英语下册Unit5_Why_do_you_like_pandas?Section_B课件
1-2_why_testing_is_necessary
5下lesson_2_why_do_you_love_zebras.ppt
信息安全_数据安全_Why_Industrial_IoT_Security_Is_R 应急响应 数据安全 威胁情报 安全管理 安全开发
「安全架构」Privacy_What_Customers_Want_Why_Security_Should_Care_and_What_to_Do_Next - 安全研究 安全实践 业务风控 攻防实训 安全实践 网络安全
信息安全_数据安全_Why_the_role_of_CISO_sucks_and_w 信息安全研究 金融安全 安全人才 安全对抗 法律法规
什么是激励函数_(深度学习)__Why_need_activation_functions_(deep_learning)_
Why use with Struts + Spring + Hibernate
七下英语Unit5_why_do_you_like_pandas_sectionB课件.ppt
33、- I believe we've met somewhere before. - No, ____________________. A:it isn't the same B:it can't be right C:I don't think so D:I'd rather not 34、--Could I use your bike for a moment? --__...
python常用脚本合集,主要是开发过程中可能用刀的一些工具类,非常好用,欢迎下载
七年级下英语Unit5Why_do_you_like_pandasSection_A-2(2012).ppt
( )6.Mum, we have _______tomatoes, but we have _______milk. Let’s buy some milk in the supermarket. A a few, little B a little , few C few, a little (三) ( )7. Lin Tao is _____ years old and ...
Emotional Design - Why we Love Or Hate everyday things
This report is for developers and architects interested in developing microservices and distributed applications. It does not explain the basics of distributed systems, but instead focuses on the ...