質問編集履歴
10
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -62,7 +62,7 @@
|
|
62
62
|
|
63
63
|
こうするとid=1のelorateは1に変わったのですが、
|
64
64
|
|
65
|
-
find(
|
65
|
+
find(:id)に書き換えるとCouldn't find Photopost with 'id'= が出ます。
|
66
66
|
|
67
67
|
どの様なコードを書けば、2枚の画像のうちクリックした方の画像のt.integer"elorate"の数値を上げ、
|
68
68
|
|
9
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
<% @photoposts.each do |photopost| %>
|
36
36
|
|
37
|
-
<%= link_to image_tag(photopost.photo_url), root_path(photopost
|
37
|
+
<%= link_to image_tag(photopost.photo_url), root_path(photopost), :method => "patch" %>
|
38
38
|
|
39
39
|
<%= photopost.elorate %>
|
40
40
|
|
@@ -42,7 +42,27 @@
|
|
42
42
|
|
43
43
|
```
|
44
44
|
|
45
|
-
photoposts_controllerのvoteアクションに飛ばし
|
45
|
+
photoposts_controllerのvoteアクションに飛ばしデータベースを更新させる。
|
46
|
+
|
47
|
+
```
|
48
|
+
|
49
|
+
def vote
|
50
|
+
|
51
|
+
photopost = Photopost.find(1)
|
52
|
+
|
53
|
+
photopost.elorate = 1 ## テストとして数値を1に変えました。
|
54
|
+
|
55
|
+
photopost.save
|
56
|
+
|
57
|
+
redirect_to root_url
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
```
|
62
|
+
|
63
|
+
こうするとid=1のelorateは1に変わったのですが、
|
64
|
+
|
65
|
+
find(params[:id])に書き換えるとCouldn't find Photopost with 'id'= が出ます。
|
46
66
|
|
47
67
|
どの様なコードを書けば、2枚の画像のうちクリックした方の画像のt.integer"elorate"の数値を上げ、
|
48
68
|
|
@@ -54,6 +74,4 @@
|
|
54
74
|
|
55
75
|
|
56
76
|
|
57
|
-
又、全く別の方法があるよ!といった場合詳しく教えて頂けると助かります。
|
58
|
-
|
59
|
-
|
77
|
+
※試行錯誤しており、何度も編集すみません。
|
8
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
<% @photoposts.each do |photopost| %>
|
36
36
|
|
37
|
-
<%= link_to image_tag(photopost.photo_url),
|
37
|
+
<%= link_to image_tag(photopost.photo_url), root_path(photopost.id), :method => "patch" %>
|
38
38
|
|
39
39
|
<%= photopost.elorate %>
|
40
40
|
|
@@ -54,10 +54,6 @@
|
|
54
54
|
|
55
55
|
|
56
56
|
|
57
|
-
追記.photopostはroutesにてresourcesで生成してます。
|
58
|
-
|
59
|
-
voteアクションに何を書いても挙動が変わりません。
|
60
|
-
|
61
57
|
又、全く別の方法があるよ!といった場合詳しく教えて頂けると助かります。
|
62
58
|
|
63
59
|
分かる方が居ましたらご教授願います。
|
7
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,6 +56,8 @@
|
|
56
56
|
|
57
57
|
追記.photopostはroutesにてresourcesで生成してます。
|
58
58
|
|
59
|
-
voteアクションに何を書いても挙動が変わ
|
59
|
+
voteアクションに何を書いても挙動が変わりません。
|
60
|
+
|
61
|
+
又、全く別の方法があるよ!といった場合詳しく教えて頂けると助かります。
|
60
62
|
|
61
63
|
分かる方が居ましたらご教授願います。
|
6
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
railsの勉強の為、facemash.comの様なサイトを作っています。
|
1
|
+
railsの勉強の為、facemash.comの様な画像比較サイトを作っています。
|
2
2
|
|
3
|
-
gemのCarrierWaveを使い、ユーザーが投稿した画像をviewの
|
3
|
+
gemのCarrierWaveを使い、ユーザーが投稿した画像を、viewのindexにてランダムで2枚のみ表示し、
|
4
4
|
|
5
|
-
link_to image_tagで生成した画像をクリックをするとデータベースを更新し、
|
5
|
+
link_to image_tagで生成した画像をクリックをするとデータベースを更新し、indexにリダイレクトされるといった機能を作りたいのですが、
|
6
6
|
|
7
7
|
詰まってしまったのでここで質問させて頂きます。
|
8
8
|
|
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
<% @photoposts.each do |photopost| %>
|
36
36
|
|
37
|
-
<%= link_to image_tag(photopost.photo_url), :action => "
|
37
|
+
<%= link_to image_tag(photopost.photo_url), :action => "vote", :method => :patch %>
|
38
38
|
|
39
39
|
<%= photopost.elorate %>
|
40
40
|
|
@@ -50,8 +50,12 @@
|
|
50
50
|
|
51
51
|
|
52
52
|
|
53
|
-
指摘・回答お願い致します。
|
53
|
+
指摘・回答宜しくお願い致します。
|
54
54
|
|
55
55
|
|
56
56
|
|
57
|
-
追記.photopostはroutesにてresourceで生成してます。
|
57
|
+
追記.photopostはroutesにてresourcesで生成してます。
|
58
|
+
|
59
|
+
voteアクションに何を書いても挙動が変わらりません。
|
60
|
+
|
61
|
+
分かる方が居ましたらご教授願います。
|
5
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
railsの勉強の為、facemash.comの様なサイトを作っています。
|
2
2
|
|
3
|
-
gemのCarrierWaveを使い、ユーザーが投稿した画像をviewの
|
3
|
+
gemのCarrierWaveを使い、ユーザーが投稿した画像をviewのshowにてランダムで2枚のみ表示し、
|
4
4
|
|
5
|
-
link_to image_tagで生成した画像をクリックをするとデータベースを更新し、また
|
5
|
+
link_to image_tagで生成した画像をクリックをするとデータベースを更新し、またshowに戻るといった機能を作りたいのですが、
|
6
6
|
|
7
7
|
詰まってしまったのでここで質問させて頂きます。
|
8
8
|
|
4
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
gemのCarrierWaveを使い、ユーザーが投稿した画像をviewのindexにてランダムで2枚のみ表示し、
|
4
4
|
|
5
|
-
link_to image_tagで生成した画像をクリックをするとデータベースを更新
|
5
|
+
link_to image_tagで生成した画像をクリックをするとデータベースを更新し、またindexに戻るといった機能を作りたいのですが、
|
6
6
|
|
7
7
|
詰まってしまったのでここで質問させて頂きます。
|
8
8
|
|
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
<% @photoposts.each do |photopost| %>
|
36
36
|
|
37
|
-
<%= link_to image_tag(photopost.photo_url), :action => "
|
37
|
+
<%= link_to image_tag(photopost.photo_url), :action => "update", :method => :patch %>
|
38
38
|
|
39
39
|
<%= photopost.elorate %>
|
40
40
|
|
@@ -51,3 +51,7 @@
|
|
51
51
|
|
52
52
|
|
53
53
|
指摘・回答お願い致します。
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
追記.photopostはroutesにてresourceで生成してます。
|
3
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
<% @photoposts.each do |photopost| %>
|
36
36
|
|
37
|
-
<%= link_to image_tag(photopost.photo_url), :action => "
|
37
|
+
<%= link_to image_tag(photopost.photo_url), :action => "vote", :method => :patch %>
|
38
38
|
|
39
39
|
<%= photopost.elorate %>
|
40
40
|
|
2
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
<% @photoposts.each do |photopost| %>
|
36
36
|
|
37
|
-
<%= link_to image_tag(photopost.photo_url), :con
|
37
|
+
<%= link_to image_tag(photopost.photo_url), :action => "update", :method => :patch %>
|
38
38
|
|
39
39
|
<%= photopost.elorate %>
|
40
40
|
|
1
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
<% @photoposts.each do |photopost| %>
|
36
36
|
|
37
|
-
<%= link_to image_tag(photopost.photo_url), :controller => "photoposts", :action => "vote"
|
37
|
+
<%= link_to image_tag(photopost.photo_url), :controller => "photoposts", :action => "vote" %>
|
38
38
|
|
39
39
|
<%= photopost.elorate %>
|
40
40
|
|