質問するログイン新規登録

質問編集履歴

2

試行結果と追記

2021/02/17 13:23

投稿

taba.3011
taba.3011

スコア12

title CHANGED
File without changes
body CHANGED
@@ -15,14 +15,6 @@
15
15
  ```
16
16
 
17
17
  ### 該当のソースコード
18
- ####Gemfile
19
- ```
20
- gem 'bootstrap-sass', '~> 3.3.6'
21
- gem 'jquery-rails'
22
- group :production, :staging do
23
- gem 'unicorn'
24
- end
25
- ```
26
18
  #####assets/stylesheets/application.scss
27
19
  ```
28
20
  省略
@@ -34,32 +26,6 @@
34
26
  @import "bootstrap-sprockets";
35
27
  @import "bootstrap";
36
28
  ```
37
- #####javascript/src/application.scss
38
- ```
39
- @import "~@fortawesome/fontawesome-free/scss/fontawesome";
40
- ```
41
- #####javascript/packs/application.js
42
- ```
43
- // This file is automatically compiled by Webpack, along with any other files
44
- // present in this directory. You're encouraged to place your actual application logic in
45
- // a relevant structure within app/javascript and only use these pack files to reference
46
- // that code so it'll be compiled.
47
- require("@rails/ujs").start()
48
- // require("turbolinks").start()
49
- require("@rails/activestorage").start()
50
- require("channels")
51
- require("./preview")
52
- require("./count")
53
-
54
- // Uncomment to copy all static images under ../images to the output folder and reference
55
- // them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
56
- // or the `imagePath` JavaScript helper below.
57
- //
58
- // const images = require.context('../images', true)
59
- // const imagePath = (name) => images(name, true)
60
-
61
- import "@fortawesome/fontawesome-free/js/all"
62
- ```
63
29
  #####config/environment/production.rb
64
30
  ```
65
31
  Rails.application.configure do
@@ -233,4 +199,32 @@
233
199
  ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
234
200
  ```
235
201
  というエラーが出ました。
236
- ここに原因がありそうと思っているのですが...話をややこしくしてしまったのか...
202
+ ここに原因がありそうと思っているのですが...話をややこしくしてしまったのか...
203
+
204
+ ###追記
205
+ #####app/assets/stylesheets/application.scss を css に書き換えてRAILS_ENV=production bundle exec rails assets:precompile実行
206
+ ![イメージ説明](de1df0d2f10619d7056c806737996160.png)
207
+ #####app/assets/config/manifest.js
208
+ ```
209
+ //= link_tree ../images
210
+ //= link_directory ../stylesheets .css
211
+ ```
212
+ #####config/initializers/assets.rb
213
+ ```
214
+ # Be sure to restart your server when you modify this file.
215
+
216
+ # Version of your assets, change this if you want to expire all your assets.
217
+ Rails.application.config.assets.version = '1.0'
218
+
219
+ # Add additional assets to the asset load path.
220
+ # Rails.application.config.assets.paths << Emoji.images_path
221
+ # Add Yarn node_modules folder to the asset load path.
222
+ Rails.application.config.assets.paths << Rails.root.join('node_modules')
223
+
224
+ # Precompile additional assets.
225
+ # application.js, application.css, and all non-JS/CSS in the app/assets
226
+ # folder are already added.
227
+ # Rails.application.config.assets.precompile += %w( admin.js admin.css )
228
+ ```
229
+ #####pp Rails.application.config.assets; の結果
230
+ ![イメージ説明](a5d2249c3c6a17c18fe97fd730423b31.png)

1

試したこと6を追記

2021/02/17 13:23

投稿

taba.3011
taba.3011

スコア12

title CHANGED
File without changes
body CHANGED
@@ -7,14 +7,7 @@
7
7
  ### 発生している問題・エラーメッセージ
8
8
 
9
9
  ```
10
- [d86058c4-3e19-4839-8911-fe7410f859ec] 7:
11
- [d86058c4-3e19-4839-8911-fe7410f859ec] 8: <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
12
- [d86058c4-3e19-4839-8911-fe7410f859ec] 9: <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW" crossorigin="anonymous"></script>
13
- [d86058c4-3e19-4839-8911-fe7410f859ec] 10: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
14
- [d86058c4-3e19-4839-8911-fe7410f859ec] 11: <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
15
- [d86058c4-3e19-4839-8911-fe7410f859ec] 12: <script src='https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.10/vue.js'></script>
16
- [d86058c4-3e19-4839-8911-fe7410f859ec] 13: <script src='https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.5/marked.js'></script>
17
- [d86058c4-3e19-4839-8911-fe7410f859ec]
10
+
18
11
  [d86058c4-3e19-4839-8911-fe7410f859ec] app/views/layouts/application.html.erb:10
19
12
  [983873fe-9610-4044-89f0-7fa37184c9f1] ActionView::Template::Error (The asset "application.css" is not present in the asset pipeline.
20
13
  ):
@@ -223,4 +216,21 @@
223
216
  どちらかに統一しなければいけないというエラーなのでしょうか...
224
217
 
225
218
  2日ほどこのエラーと戦っているのですが、設定ファイルをいじったりunicornやnginxを再起動しまくっているうちに、何が何だかわからなくなってしまいました。
226
- 解決方法をご存知の方がいらっしゃれば、ぜひご教授していただけると幸いです
219
+ 解決方法をご存知の方がいらっしゃれば、ぜひご教授していただけると幸いです
220
+
221
+ ####追記 試したこと6
222
+ シークレットキーあたりが怪しいと思い、
223
+ ローカル環境で一度credentials.yml.encファイルを削除し、作り直しました。
224
+ ```
225
+ rm credentials.yml.enc
226
+ ```
227
+ ```
228
+ rails credentials:edit
229
+ ```
230
+ その後、ec2内の方のアプリのcredentials.yml.encファイルに、ローカル環境で作り直したcredentials.yml.encをコピーしました。
231
+ それからbundle exec rails assets:precompile RAILS_ENV=productionを実行すると、
232
+ ```
233
+ ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
234
+ ```
235
+ というエラーが出ました。
236
+ ここに原因がありそうと思っているのですが...話をややこしくしてしまったのか...