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

質問編集履歴

1

全体的にわかりやすい記述に変更しました。

2021/04/25 10:55

投稿

danburudoa
danburudoa

スコア8

title CHANGED
@@ -1,1 +1,1 @@
1
- AWSで背景画像が表示できない
1
+ AWSでimage-url記述するとデプロイできない
body CHANGED
@@ -1,36 +1,18 @@
1
1
  現在、AWSサーバーで自動デプロイツールCapistranoを用いて、トップ画面の背景画像を表示させようとしています。しかし、調べた内容で修正してもbundle exec cap production deployを実行し、デプロイした時にエラーが起きてしまいます。
2
2
  記述はscss内で書いています。
3
3
  ##試した記述
4
+ background: transparent url(image_path('mainvisual.png')) no-repeat top center / cover;
4
- これま、調べて試した記述とエラー内容を3パターン載せした
5
+ で記述する、デプロイできるのですが、背景画像が表示されせん
5
6
  ```
6
7
 
7
8
  boards.scss
8
9
 
9
- background: transparent url(image_path('mainvisual.png')) no-repeat top center / cover;
10
+ background: transparent image-url(image_path('mainvisual.png')) no-repeat top center / cover;
10
11
 
11
12
  エラー内容
12
13
  NoMethodError: undefined method `[]' for nil:NilClass
13
14
  ```
14
15
 
15
- ```
16
-
17
- board.scss
18
-
19
- background-image: url(<%= asset_path 'mainvisual.png' %>);
20
-
21
- エラー内容
22
- Sass::SyntaxError: Invalid CSS after "...und-image: url(": expected ")", was "<%= asset_path ..."
23
- ```
24
-
25
- ```
26
-
27
- board.scss
28
-
29
- background-image:image-url('mainvisual.png');
30
-
31
- エラー内容
32
- NoMethodError: undefined method `[]' for nil:NilClass
33
- ```
34
16
  ##補足情報
35
17
  画像はapp/assets/imagesの中に入れています。
36
18
  必要な情報がありましたら、言っていただければと思います。