質問編集履歴
1
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,7 +10,9 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
+
|
14
|
+
|
13
|
-
### コード
|
15
|
+
### 該当のソースコード
|
14
16
|
|
15
17
|
```ruby
|
16
18
|
|
@@ -20,6 +22,132 @@
|
|
20
22
|
|
21
23
|
```
|
22
24
|
|
25
|
+
app/controllers/resumes_controller.rb
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
|
29
|
+
class ResumesController < ApplicationController
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
def show
|
36
|
+
|
37
|
+
@resume = Resume.find(current_user_devise.id)
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
@user_devise = UserDevise.find(@resume.user_devise_id)
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
respond_to do |format|
|
46
|
+
|
47
|
+
format.html
|
48
|
+
|
49
|
+
format.pdf do
|
50
|
+
|
51
|
+
render pdf: 'filename', # PDF名
|
52
|
+
|
53
|
+
template: 'resumes/show.html.erb', # viewを対象にする
|
54
|
+
|
55
|
+
orientation: 'Landscape', # 横向き
|
56
|
+
|
57
|
+
page_size: 'A4' # ページサイズ
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
```
|
72
|
+
|
73
|
+
config/routes.rb
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
|
77
|
+
Rails.application.routes.draw do
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
get 'resumes/show', to: 'resumes#show'
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
```
|
88
|
+
|
89
|
+
app/views/layouts/pdf_template.html.erb
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
|
93
|
+
<!DOCTYPE html>
|
94
|
+
|
95
|
+
<html>
|
96
|
+
|
97
|
+
<head>
|
98
|
+
|
99
|
+
<title>Wicked PDF</title>
|
100
|
+
|
101
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
102
|
+
|
103
|
+
<%= wicked_pdf_stylesheet_link_tag 'application', 'data-turbolinks-track': 'reload' %>
|
104
|
+
|
105
|
+
<%= wicked_pdf_javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
106
|
+
|
107
|
+
</head>
|
108
|
+
|
109
|
+
<body>
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
<%= yield %>
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
</body>
|
118
|
+
|
119
|
+
</html>
|
120
|
+
|
121
|
+
```
|
122
|
+
|
123
|
+
app/views/resumes/show.html.erb
|
124
|
+
|
125
|
+
こちらのhtmlがPDFとして出力されていますが、Heroku で日本語のみ表示されません。
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
|
129
|
+
<html>
|
130
|
+
|
131
|
+
<head>
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
136
|
+
|
137
|
+
</head>
|
138
|
+
|
139
|
+
<body>
|
140
|
+
|
141
|
+
aaaaあああ
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
</body>
|
146
|
+
|
147
|
+
</html>
|
148
|
+
|
149
|
+
```
|
150
|
+
|
23
151
|
|
24
152
|
|
25
153
|
|