質問編集履歴
1
あ
test
CHANGED
File without changes
|
test
CHANGED
@@ -67,3 +67,65 @@
|
|
67
67
|
|
68
68
|
|
69
69
|
```
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
追記:下記のように修正しました。NoMethodErrorがでます。
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
・コントローラー
|
78
|
+
|
79
|
+
index_controller.rb
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
|
83
|
+
class HomesController < ApplicationController
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
def index
|
88
|
+
|
89
|
+
@db_user = User.user_info
|
90
|
+
|
91
|
+
render "homes/index"
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
```
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
・モデル
|
106
|
+
|
107
|
+
user.rb
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
|
111
|
+
class User < ApplicationRecord
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
def user_info
|
116
|
+
|
117
|
+
user = User.find(1)
|
118
|
+
|
119
|
+
info = user.name
|
120
|
+
|
121
|
+
return info
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
```
|