Skip to content

Commit 9888456

Browse files
committed
Add Emojoy refinement to add some joy to flash messages
1 parent fbf4013 commit 9888456

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

app/controllers/share/snippet_screenshots_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
class Share::SnippetScreenshotsController < ApplicationController
2+
using Refinements::Emojoy
3+
24
def show
35
@snippet = Snippet.find(params[:snippet_id])
46

@@ -12,6 +14,6 @@ def new
1214
def create
1315
@snippet = Snippet.find(params[:snippet_id])
1416
@snippet.attach_screenshot_from_base64(params[:screenshot])
15-
redirect_to share_snippet_url(@snippet), notice: "Screenshot attached."
17+
redirect_to share_snippet_url(@snippet), notice: "Screenshot attached".emojoy
1618
end
1719
end

app/controllers/share/snippets_controller.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
class Share::SnippetsController < ApplicationController
2+
using Refinements::Emojoy
3+
24
before_action :feature_enabled!
35

46
# GET /snippets
@@ -32,7 +34,7 @@ def create
3234
@snippet = Snippet.new(snippet_params)
3335

3436
if @snippet.save
35-
redirect_to share_snippet_redirect_url(@snippet), notice: "Snippet was successfully created."
37+
redirect_to share_snippet_redirect_url(@snippet), notice: "Your snippet has been saved".emojoy, status: :see_other
3638
else
3739
render :new, status: :unprocessable_entity
3840
end
@@ -44,7 +46,7 @@ def update
4446
if @snippet.update(snippet_params)
4547
@snippet.attach_screenshot_from_base64(params[:screenshot]) if params[:screenshot]
4648

47-
redirect_to share_snippet_redirect_url(@snippet), notice: "Snippet was successfully updated.", status: :see_other
49+
redirect_to share_snippet_redirect_url(@snippet), notice: "Your snippet has been saved".emojoy, status: :see_other
4850
else
4951
render :edit, status: :unprocessable_entity
5052
end

app/lib/refinements/emojoy.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module Refinements
2+
module Emojoy
3+
EMOJOYS = %w[🎸 🚴🏼‍♂️ 🛜 🍿 👻 🤠 ✌️ 🦸🏻‍♀️ 🐙 🌈 ⚡️ 🔥 🏆].freeze
4+
5+
refine String do
6+
def emojoy
7+
self + " #{EMOJOYS.sample}"
8+
end
9+
end
10+
end
11+
end

0 commit comments

Comments
 (0)