質問編集履歴
1
追加情報
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,7 +1,169 @@
|
|
1
|
-
テラテイルにもあるようなfooterにお問い合わせフォームを作りたいのですがどうしたら良いでしょうか
|
1
|
+
**ボールドテキスト**テラテイルにもあるようなfooterにお問い合わせフォームを作りたいのですがどうしたら良いでしょうか
|
2
2
|
|
3
3
|
|
4
4
|
|
5
5
|
ideaというコントローラーで作って<%= render partial: 'ideas/form' %>で呼び出しましたが
|
6
6
|
|
7
7
|
First argument in form cannot contain nil or be emptyとエラーになります。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
```lang-ruby
|
16
|
+
|
17
|
+
class IdeasController < ApplicationController
|
18
|
+
|
19
|
+
before_action :set_idea, only: [:show, :edit, :update, :destroy]
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
# GET /ideas
|
24
|
+
|
25
|
+
# GET /ideas.json
|
26
|
+
|
27
|
+
def index
|
28
|
+
|
29
|
+
@ideas = Idea.all
|
30
|
+
|
31
|
+
@idea = Idea.new
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
# GET /ideas/1
|
38
|
+
|
39
|
+
# GET /ideas/1.json
|
40
|
+
|
41
|
+
def show
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
# GET /ideas/new
|
48
|
+
|
49
|
+
def new
|
50
|
+
|
51
|
+
@idea = Idea.new
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
# GET /ideas/1/edit
|
58
|
+
|
59
|
+
def edit
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
# POST /ideas
|
66
|
+
|
67
|
+
# POST /ideas.json
|
68
|
+
|
69
|
+
def create
|
70
|
+
|
71
|
+
@idea = Idea.new(idea_params)
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
respond_to do |format|
|
76
|
+
|
77
|
+
if @idea.save
|
78
|
+
|
79
|
+
format.html { redirect_to @idea, notice: 'Idea was successfully created.' }
|
80
|
+
|
81
|
+
format.json { render :show, status: :created, location: @idea }
|
82
|
+
|
83
|
+
else
|
84
|
+
|
85
|
+
format.html { render :new }
|
86
|
+
|
87
|
+
format.json { render json: @idea.errors, status: :unprocessable_entity }
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
# PATCH/PUT /ideas/1
|
98
|
+
|
99
|
+
# PATCH/PUT /ideas/1.json
|
100
|
+
|
101
|
+
def update
|
102
|
+
|
103
|
+
respond_to do |format|
|
104
|
+
|
105
|
+
if @idea.update(idea_params)
|
106
|
+
|
107
|
+
format.html { redirect_to @idea, notice: 'Idea was successfully updated.' }
|
108
|
+
|
109
|
+
format.json { render :show, status: :ok, location: @idea }
|
110
|
+
|
111
|
+
else
|
112
|
+
|
113
|
+
format.html { render :edit }
|
114
|
+
|
115
|
+
format.json { render json: @idea.errors, status: :unprocessable_entity }
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
# DELETE /ideas/1
|
126
|
+
|
127
|
+
# DELETE /ideas/1.json
|
128
|
+
|
129
|
+
def destroy
|
130
|
+
|
131
|
+
@idea.destroy
|
132
|
+
|
133
|
+
respond_to do |format|
|
134
|
+
|
135
|
+
format.html { redirect_to ideas_url, notice: 'Idea was successfully destroyed.' }
|
136
|
+
|
137
|
+
format.json { head :no_content }
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
private
|
146
|
+
|
147
|
+
# Use callbacks to share common setup or constraints between actions.
|
148
|
+
|
149
|
+
def set_idea
|
150
|
+
|
151
|
+
@idea = Idea.find(params[:id])
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
# Never trust parameters from the scary internet, only allow the white list through.
|
158
|
+
|
159
|
+
def idea_params
|
160
|
+
|
161
|
+
params.require(:idea).permit(:body)
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
```
|