質問編集履歴

1

Sitesモデルクラスのソース、SiteモデルのDBスキーマを追記しました。

2016/04/07 01:30

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -58,6 +58,44 @@
58
58
 
59
59
  .
60
60
 
61
+
62
+
63
+ スキーマ
64
+
65
+ create_table "sites", force: :cascade do |t|
66
+
67
+ t.string "name"
68
+
69
+ t.string "link"
70
+
71
+ t.datetime "created_at", null: false
72
+
73
+ t.datetime "updated_at", null: false
74
+
75
+ t.integer "user_id"
76
+
77
+ migrateフォルダの中
78
+
79
+ class AddUserIdToSites < ActiveRecord::Migration
80
+
81
+ def change
82
+
83
+ add_column :sites, :user_id, :integer
84
+
85
+ end
86
+
87
+ end
88
+
89
+
90
+
91
+ sitesのモデルクラス
92
+
93
+ class Site < ActiveRecord::Base
94
+
95
+ belongs_to :user
96
+
97
+ end
98
+
61
99
  ```
62
100
 
63
101