質問編集履歴
1
コントローラー、ビュー、routes\.rbを追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -23,3 +23,153 @@
|
|
23
23
|
アップローダー CarrierWave
|
24
24
|
|
25
25
|
画像を保存するサーバー amazon s3
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
###コントローラー
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
```rails
|
34
|
+
|
35
|
+
def show
|
36
|
+
|
37
|
+
@user = User.find_by(user_id: params[:user_id])
|
38
|
+
|
39
|
+
@users_gallery = @user.galleries.all.order(created_at: :desc)
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def set_user
|
48
|
+
|
49
|
+
@user = User.find_by(user_id: params[:user_id])
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
```
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
###ビュー
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
```rails
|
62
|
+
|
63
|
+
<div id="fullpage">
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
<div class="section" id="user-profile">
|
74
|
+
|
75
|
+
<div class="slide">
|
76
|
+
|
77
|
+
<div class="img-wrap">
|
78
|
+
|
79
|
+
<%= image_tag @user.user_image, class: 'img' if @user.user_image %> ←ここが表示されません。
|
80
|
+
|
81
|
+
</div>
|
82
|
+
|
83
|
+
<div class="txt-wrap">
|
84
|
+
|
85
|
+
<h2><%= @user.user_name %></h2>
|
86
|
+
|
87
|
+
<p><%= "@" + @user.user_id %></p>
|
88
|
+
|
89
|
+
<p>ギャラリー数: <%= @user.galleries.size %></p>
|
90
|
+
|
91
|
+
<% if user_signed_in? %>
|
92
|
+
|
93
|
+
<% if current_user.id == @user.id %>
|
94
|
+
|
95
|
+
<p><%= link_to '編集', edit_user_path(@user.user_id) %></p>
|
96
|
+
|
97
|
+
<% end %>
|
98
|
+
|
99
|
+
<% end %>
|
100
|
+
|
101
|
+
</div>
|
102
|
+
|
103
|
+
</div>
|
104
|
+
|
105
|
+
</div>
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
<% @users_gallery.each do |gallery| %>
|
114
|
+
|
115
|
+
<div class="section" id="slide-top">
|
116
|
+
|
117
|
+
<div class="slide">
|
118
|
+
|
119
|
+
<div class="img-wrap">
|
120
|
+
|
121
|
+
<%= link_to image_tag(gallery.image,{:class => "img"}), gallery_path(gallery.id) %>
|
122
|
+
|
123
|
+
</div>
|
124
|
+
|
125
|
+
<div class="txt-wrap">
|
126
|
+
|
127
|
+
<h2><%= link_to gallery.title, gallery_path(gallery.id) %></h2>
|
128
|
+
|
129
|
+
<p><%= link_to gallery.user.user_name, user_path(gallery.user.user_id) %>
|
130
|
+
|
131
|
+
(<%= link_to "@" + gallery.user.user_id, user_path(gallery.user.user_id) %>)</p>
|
132
|
+
|
133
|
+
<p>作品数: <%= gallery.works.size %></p>
|
134
|
+
|
135
|
+
</div>
|
136
|
+
|
137
|
+
</div>
|
138
|
+
|
139
|
+
</div>
|
140
|
+
|
141
|
+
<% end %>
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
</div>
|
152
|
+
|
153
|
+
```
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
###routes.rb
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
```rails
|
162
|
+
|
163
|
+
Rails.application.routes.draw do
|
164
|
+
|
165
|
+
devise_for :users
|
166
|
+
|
167
|
+
resources :users, param: :user_id, path: '/', only: [:show, :edit, :update, :destroy]
|
168
|
+
|
169
|
+
resources :galleries
|
170
|
+
|
171
|
+
root 'home#top'
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
```
|