Created
September 14, 2012 02:11
-
-
Save keating/3719388 to your computer and use it in GitHub Desktop.
给关联关系赋值,发生了什么?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 给关联关系赋值,发生了什么? | |
@sme = Sme.find(params[:id]) | |
@sme.sme_inspections = @sme.build_inspections params[:inspections] | |
# @sme.sme_inspections的class是个array,@sme.build_inspections params[:inspections] 只不过构造了一个sme_inspection的数组,并且数组中sme_inspection的sme_id为空 | |
# 但接下来发生了这些 | |
#SmeInspection Load (0.7ms) SELECT "sme_inspections".* FROM "sme_inspections" WHERE "sme_inspections"."sme_id" = 29 | |
#UPDATE "sme_inspections" SET "sme_id" = NULL WHERE "sme_inspections"."sme_id" = 29 AND "sme_inspections"."id" IN (49) | |
#INSERT INTO "sme_inspections" ("auditor", "created_at"...) VALUES ($1, $2, $3, $4, $5, $6, $7) | |
# 太强大了。。。。。不过,这个特性好像也没什么用? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment