回答編集履歴

6

てs

2017/04/12 09:28

投稿

moke
moke

スコア2241

test CHANGED
@@ -62,7 +62,7 @@
62
62
 
63
63
  respond_to |format|
64
64
 
65
- format.html{render show}
65
+ format.html{render :show}
66
66
 
67
67
  format.js{}
68
68
 

5

たん

2017/04/12 09:28

投稿

moke
moke

スコア2241

test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  #略
10
10
 
11
- <div><%= link_to(@question.is_solved '解決済み':'受付中',{controller: :questions,action: :make_resolved}) %></div>
11
+ <div><%= link_to(@question.is_solved ? '解決済み':'受付中',{controller: :questions,action: :make_resolved}) %></div>
12
12
 
13
13
 
14
14
 

4

\?

2017/04/12 09:27

投稿

moke
moke

スコア2241

test CHANGED
@@ -32,7 +32,7 @@
32
32
 
33
33
  ```ruby
34
34
 
35
- <%= link_to(question.is_solved '解決済み':'受付中',{controller: :questions,action: :make_resolved}) %>
35
+ <%= link_to(question.is_solved ? '解決済み':'受付中',{controller: :questions,action: :make_resolved}) %>
36
36
 
37
37
  ```
38
38
 

3

シンボルにしました

2017/04/12 09:26

投稿

moke
moke

スコア2241

test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  #略
10
10
 
11
- <div><%= link_to(@question.is_solved '解決済み':'受付中',{controller: questions,action: :make_resolved}) %></div>
11
+ <div><%= link_to(@question.is_solved '解決済み':'受付中',{controller: :questions,action: :make_resolved}) %></div>
12
12
 
13
13
 
14
14
 
@@ -32,7 +32,7 @@
32
32
 
33
33
  ```ruby
34
34
 
35
- <%= link_to(question.is_solved '解決済み':'受付中',{controller: questions,action: :make_resolved}) %>
35
+ <%= link_to(question.is_solved '解決済み':'受付中',{controller: :questions,action: :make_resolved}) %>
36
36
 
37
37
  ```
38
38
 

2

2017/04/12 09:19

投稿

moke
moke

スコア2241

test CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  <div><%= link_to(@question.is_solved '解決済み':'受付中',{controller: questions,action: :make_resolved}) %></div>
12
12
 
13
- <% end %>
13
+
14
14
 
15
15
  ```
16
16
 
@@ -44,12 +44,32 @@
44
44
 
45
45
  $("#ajax_button").append('<%= escape_javascript render :partial => "make_resolved" ,locals: {question: @question},:layout => false %>');
46
46
 
47
- <% end %>
48
-
49
47
  ```
50
48
 
51
49
  とすれば動くと思います。
52
50
 
53
51
 
54
52
 
53
+ あっ忘れてた
55
54
 
55
+ ```ruby
56
+
57
+ if @question.update(is_solved: true)
58
+
59
+ //
60
+
61
+ end
62
+
63
+ respond_to |format|
64
+
65
+ format.html{render show}
66
+
67
+ format.js{}
68
+
69
+ end
70
+
71
+
72
+
73
+ ```
74
+
75
+ controllerにrespond_toを入れてjsでのリクエストを許容する必要があります。

1

m

2017/04/12 07:45

投稿

moke
moke

スコア2241

test CHANGED
@@ -4,13 +4,11 @@
4
4
 
5
5
  ```ruby
6
6
 
7
- <%= form_for @question do |f| %>
8
7
 
9
- <div><%= f.text_feld :title %></div>
10
8
 
11
9
  #略
12
10
 
13
- <div><%= f.submit,(f.object.is_solved '解決済み':'受付中') %></div>
11
+ <div><%= link_to(@question.is_solved '解決済み':'受付中',{controller: questions,action: :make_resolved}) %></div>
14
12
 
15
13
  <% end %>
16
14
 
@@ -20,15 +18,11 @@
20
18
 
21
19
  ```ruby
22
20
 
23
- <%= form_for @question do |f| %>
24
21
 
25
- <div><%= f.text_feld :title %></div>
26
22
 
27
23
  #略
28
24
 
29
- <div id='ajax_button'><%= render :partial=>'make_resolved' ,locals=>{f: f} %></div>
25
+ <div id='ajax_button'><%= render :partial=>'make_resolved' ,locals=>{question: @question} %></div>
30
-
31
- <% end %>
32
26
 
33
27
  ```
34
28
 
@@ -38,7 +32,7 @@
38
32
 
39
33
  ```ruby
40
34
 
41
- <%= f.submit,(f.object.is_solved '解決済み':'受付中') %>
35
+ <%= link_to(question.is_solved '解決済み':'受付中',{controller: questions,action: :make_resolved}) %>
42
36
 
43
37
  ```
44
38
 
@@ -46,14 +40,16 @@
46
40
 
47
41
  ```ruby
48
42
 
49
- <%= form_for @question do |f| %>
50
-
51
43
  $("#ajax_button").children().remove();
52
44
 
53
- $("#ajax_button").append('<%= escape_javascript render :partial => "make_resolved" ,locals: {f: f},:layout => false %>');
45
+ $("#ajax_button").append('<%= escape_javascript render :partial => "make_resolved" ,locals: {question: @question},:layout => false %>');
54
46
 
55
47
  <% end %>
56
48
 
57
49
  ```
58
50
 
59
51
  とすれば動くと思います。
52
+
53
+
54
+
55
+