質問するログイン新規登録

質問編集履歴

1

全体

2015/11/23 12:23

投稿

y.akihiro
y.akihiro

スコア12

title CHANGED
@@ -1,1 +1,1 @@
1
- PG::UndefinedTable: ERROR: relation "categories_people_people" エラが治せません
1
+ railsでデタを削除できません
body CHANGED
@@ -1,19 +1,15 @@
1
1
  ```ここに言語を入力
2
- PG::UndefinedTable: ERROR: relation "categories_people_people" does not exist
3
- LINE 5: WHERE a.attrelid = '"categories_people_people...
4
- ^
5
- : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
6
- pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
7
- FROM pg_attribute a LEFT JOIN pg_attrdef d
8
- ON a.attrelid = d.adrelid AND a.attnum = d.adnum
9
- WHERE a.attrelid = '"categories_people_people"'::regclass
10
- AND a.attnum > 0 AND NOT a.attisdropped
11
- ORDER BY a.attnum
2
+ PG::ForeignKeyViolation: ERROR: update or delete on table "people" violates foreign key constraint "fk_rails_c7c0232d36" on table "categories_people" DETAIL: Key (id)=(2) is still referenced from table "categories_people". : DELETE FROM "people" WHERE "people"."id" = $1
12
3
  ```
13
4
 
14
- 上記の
15
- ```ここに言語を入力
5
+ 上記のようなエラーが出ました。
6
+
7
+ personとperiodとcategoryの3つのテーブルがあります。
8
+ そして、personと同時にperiodとcategoryを登録できるようになっています。
16
- WHERE a.attrelid = '"categories_people_people"'::regclass
9
+ personとperiod、personとcategoryが紐付けされている2つの中間テーブルが存在しています。
17
- ```
10
+
18
- この行の '"categories_people_people"' この部分を'"categories_people"'に変えたいです.
19
- あと、'"categories_people_people"'ここ影響与えてるのは、どこですか?例えばコントローラーやモル、ビュなど教えてください
11
+ 中間テーブルデータ送っ登録や変更をすることはきているんで、データを削除することがきません。削除しようとするとエラーが出ます。
12
+
13
+ 多分modelの設定が間違ってると思うんですが、どうすればいいかわかりません。
14
+ 中間テーブルは、belongs_toを使っています。
15
+ それ以外は、has_manyやthroughを使っています。