質問編集履歴
1
追加情報
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,85 @@
|
|
1
|
-
テラテイルにもあるようなfooterにお問い合わせフォームを作りたいのですがどうしたら良いでしょうか
|
1
|
+
**ボールドテキスト**テラテイルにもあるようなfooterにお問い合わせフォームを作りたいのですがどうしたら良いでしょうか
|
2
2
|
|
3
3
|
ideaというコントローラーで作って<%= render partial: 'ideas/form' %>で呼び出しましたが
|
4
|
-
First argument in form cannot contain nil or be emptyとエラーになります。
|
4
|
+
First argument in form cannot contain nil or be emptyとエラーになります。
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
```lang-ruby
|
9
|
+
class IdeasController < ApplicationController
|
10
|
+
before_action :set_idea, only: [:show, :edit, :update, :destroy]
|
11
|
+
|
12
|
+
# GET /ideas
|
13
|
+
# GET /ideas.json
|
14
|
+
def index
|
15
|
+
@ideas = Idea.all
|
16
|
+
@idea = Idea.new
|
17
|
+
end
|
18
|
+
|
19
|
+
# GET /ideas/1
|
20
|
+
# GET /ideas/1.json
|
21
|
+
def show
|
22
|
+
end
|
23
|
+
|
24
|
+
# GET /ideas/new
|
25
|
+
def new
|
26
|
+
@idea = Idea.new
|
27
|
+
end
|
28
|
+
|
29
|
+
# GET /ideas/1/edit
|
30
|
+
def edit
|
31
|
+
end
|
32
|
+
|
33
|
+
# POST /ideas
|
34
|
+
# POST /ideas.json
|
35
|
+
def create
|
36
|
+
@idea = Idea.new(idea_params)
|
37
|
+
|
38
|
+
respond_to do |format|
|
39
|
+
if @idea.save
|
40
|
+
format.html { redirect_to @idea, notice: 'Idea was successfully created.' }
|
41
|
+
format.json { render :show, status: :created, location: @idea }
|
42
|
+
else
|
43
|
+
format.html { render :new }
|
44
|
+
format.json { render json: @idea.errors, status: :unprocessable_entity }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# PATCH/PUT /ideas/1
|
50
|
+
# PATCH/PUT /ideas/1.json
|
51
|
+
def update
|
52
|
+
respond_to do |format|
|
53
|
+
if @idea.update(idea_params)
|
54
|
+
format.html { redirect_to @idea, notice: 'Idea was successfully updated.' }
|
55
|
+
format.json { render :show, status: :ok, location: @idea }
|
56
|
+
else
|
57
|
+
format.html { render :edit }
|
58
|
+
format.json { render json: @idea.errors, status: :unprocessable_entity }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# DELETE /ideas/1
|
64
|
+
# DELETE /ideas/1.json
|
65
|
+
def destroy
|
66
|
+
@idea.destroy
|
67
|
+
respond_to do |format|
|
68
|
+
format.html { redirect_to ideas_url, notice: 'Idea was successfully destroyed.' }
|
69
|
+
format.json { head :no_content }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
# Use callbacks to share common setup or constraints between actions.
|
75
|
+
def set_idea
|
76
|
+
@idea = Idea.find(params[:id])
|
77
|
+
end
|
78
|
+
|
79
|
+
# Never trust parameters from the scary internet, only allow the white list through.
|
80
|
+
def idea_params
|
81
|
+
params.require(:idea).permit(:body)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
```
|