version: Rails 4.1
8 Active Record and Referential Integrity 相关的完整性
Active Record 一直要求的是把智能化放在你的模型中, 而不是数据库中. 同样地, 类似于触发器或者外键限制的特征不能被过度使用, 这样会把一些智能化放回至数据库中.
类似于 validates :foreign_key, uniqueness :true 的验证是一种方式, 用在模型中能够保持数据的完整性. 属性 :dependent 在关联性上允许模型自动化地来销毁子对象, 是在当父对象被销毁的时候. 就如同那些在应用级的操作, 这些不能够保证相关的完整性, 因此有些人在数据库中用外键的限制来扩展他们.
虽然 Active Record 没有直接在执行这些特征时, 提供任何工具, execute 方法能够被用来执行任意的SQL. 你也可以使用一个 gem 类似于 foreigner , 用来增加Active Record 的外键支持(包括支持输出外键到 db/schema.rb).
相关推荐
Rails 3中的Active Record的查询变化.doc
Pro Active Record. Databases with Ruby and Rails
active_record_upsert, Rails 5/Active Record 5的更新更新 ActiveRecordUpsertpostgre 9.5 和 Rails 5/ActiveRecord 5的真正更新。 在冲突时使用进行更新。的主要点是否在单个记录上使用 ON CONFLICT DO U
Get your front end working with Webpack, use Postgres' features from migrations, and write unit tests for all of it. All of this within Rails 5. You'll gain the confidence to work at every level of ...
gem "mongoid_rails_migrations" 如何使用 创建迁移 $ rails generate mongoid:migration 运行迁移: $ rails db:migrate $ rails db:migrate:down VERSION= $ rails db:migrate:up VERSION= $ rails db:rollback...
mongoid_rails_migrations, Mongoid的数据迁移 发行说明最新版本,1.1. x, 目标 Mongoid> = 4.0.0和 Rails> = 4.2.0.对于 Rails> = 3.2.0和 Mongoid> = 3.0.0,使用版本 1.0.0.
Ruby on Rails Guides_ A Guide to Active Record Associations.pdf
rails generate active_record:session_migration 运行迁移: rake db:migrate 然后,在config/initializers/session_store.rb设置会话存储: Rails . application . config . session_store :active_record_...
ActiveRecordUpsert PostgreSQL 9.5+和Rails 5+ / ActiveRecord 5+的真实更新。 使用 。 要点 使用ON CONFLICT DO UPDATE在单个记录... gem 'active_record_upsert' 然后执行: $ bundle 或将其自己安装为: $ gem
Pro.Active.Record.Databases.with.Ruby.and.Rails
gem 'active_record_migrations' gem 'sqlite3' # or 'pg', 'mysql2', ... 然后执行: $ bundle --binstubs 创建一个Rakefile: require 'active_record_migrations' ActiveRecordMigrations.load_tasks 用法 ...
这是Rocket Job原始库的略微修改,只是将其从active_record_slave重命名为active_record_replica 。 为了更清楚地将库与active_record_slave区别开来,我们还增加了主版本–但是,它在功能上是等效的。 介绍 active...
rails-angular-postgres-and-bootstrap-second-edition 英文原版
This concise teaches you how to use the power of Docker and Kubernetes to deploy your Rails applications easily and efficiently. Docker and Kubernetes are increasing in popularity every day, but what ...
Booleanize 是一个 Ruby on Rails 插件,它添加了新方法来帮助您处理模型的布尔属性。 基本上,它为每个指定的布尔属性创建两个新的实例方法和两个命名范围。 实例方法 假设您在 User 模型中有一个名为active的...
As a Rails developer, you care about user experience and performance, but you also want simple and maintainable code. Achieve all that by embracing the full stack of web development, from styling with...
Rails, Angular, Postgres, and Bootstrap(2nd) 英文epub 第2版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
In Part II, you'll take your skills to the next level as you build a social networking app with more advanced Ruby tools, such as ...and advanced data modeling techniques within Rails's Active Record....
Rails, Angular, Postgres, and Bootstrap(2nd),电子书实战版