Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.

Commit 2b1c3bb

Browse files
committed
Webpacker image in Rails view example
1 parent bd789b6 commit 2b1c3bb

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

app/javascript/images/avatar.png

11.6 KB
Loading

app/javascript/packs/application.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import Turbolinks from "turbolinks"
88
import * as ActiveStorage from "@rails/activestorage"
99
import "channels"
1010

11+
const images = require.context("../images", true)
12+
const imagePath = name => images(name, true)
13+
1114
Rails.start()
1215
Turbolinks.start()
1316
ActiveStorage.start()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
11
<h1>Welcome to the best page on this website</h1>
2+
3+
<h2>On image loading:</h2>
4+
<p>
5+
A long time ago, while I was at my first contract ever, my client used
6+
Google Chat to keep in touch with everyone since we were all remote except
7+
the one day every other week we collected in Big Rapids at 7-o-****ing-clock.
8+
They also made me use Subversion, which was mostly a huge pain in the ass,
9+
but I was too green to know it at the time.
10+
</p>
11+
<p>
12+
I digress: Google Chat wasn't as good as Slack, but it did let me upload this
13+
kickass avatar which I made in under 5 minutes using a touchpad in MS Paint.
14+
The contract is long over, but this avatar is now plastered all over every
15+
profile I've made or updated since then. Weird what stuff sticks with us.
16+
</p>
17+
<p>
18+
Anyway, here's an image I loaded with Webpacker:
19+
</p>
20+
<%= image_pack_tag "media/images/avatar.png" %>

0 commit comments

Comments
 (0)