![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Ruby入门
kelley_luxuiary
这个作者很懒,什么都没留下…
展开
-
Active Record 迁移change
change 方法是编写迁移时最常用的。在大多数情况下,Active Record 知道如何自动撤销用 change 方法编写的迁移。目前,在 change 方法中只能使用下面这些方法:▪ add_column▪ add_foreign_key▪ add_index▪ add_reference▪ add_timestamps▪ change_column_default (必须提供...原创 2019-08-19 17:12:30 · 95 阅读 · 0 评论 -
Active Record 撤销迁移reversible
class ExampleMigration < ActiveRecord::Migration[5.2] def change create_table :distributors do |t| t.string :zipcode end reversible do |dir| dir....原创 2019-08-19 17:15:16 · 119 阅读 · 0 评论 -
ActiveRecord db
回滚$ bin/rails db:rollback:通过撤销 change 方法或调用 down 方法来回滚最后一个迁移。要想取消多个迁移,可以使用 STEP参数:$ bin/rails db:rollback STEP=N(撤销最后N步骤)db:migrate:redo 任务用于回滚最后一个迁移并再次运行这个迁移。和 db:rollback 任务一样,如果需要重做多个迁移,可以...原创 2019-08-19 17:26:57 · 136 阅读 · 0 评论 -
ActiveRecord 校验和跳过校验的方法
触发数据验证,如果验证失败就不把对象存入数据库:▪ create▪ create!▪ save▪ save!▪ update▪ update!爆炸方法(例如 save! )会在验证失败后抛出异常。验证失败后,非爆炸方法不会抛出异常;save 和 update返回 false , create 返回对象本身。跳过验证,不管验证是否通过都会把对象存入数据库,使用时要特别留意。▪ ...原创 2019-08-19 17:38:38 · 520 阅读 · 0 评论 -
VS code的WSL 下git clone
VS code的WSL 下git clone1. sudo apt-get install git2. sudo git config --global user.name "xxx"3. sudo git config --global user.email "XX"4. git config --list5. ssh-keygen -t rsa -C "804944518@qq.c...原创 2019-08-22 16:45:31 · 1126 阅读 · 0 评论