From 88f499d11433fcb519b02608fd58fa0355093620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 1 Jul 2023 21:39:41 +0200 Subject: [PATCH] Simplify passing parameters in FollowsController --- app/controllers/follows_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/follows_controller.rb b/app/controllers/follows_controller.rb index 66fbb6a50..a9db098c0 100644 --- a/app/controllers/follows_controller.rb +++ b/app/controllers/follows_controller.rb @@ -4,13 +4,13 @@ class FollowsController < ApplicationController def create @follow.save! - flash.now[:notice] = t("shared.followable.#{followable_translation_key(@follow.followable)}.create.notice") + flash.now[:notice] = t("shared.followable.#{followable_translation_key(@follow)}.create.notice") render :refresh_follow_button end def destroy @follow.destroy! - flash.now[:notice] = t("shared.followable.#{followable_translation_key(@follow.followable)}.destroy.notice") + flash.now[:notice] = t("shared.followable.#{followable_translation_key(@follow)}.destroy.notice") render :refresh_follow_button end @@ -24,7 +24,7 @@ class FollowsController < ApplicationController [:followable_type, :followable_id] end - def followable_translation_key(followable) - followable.class.name.parameterize(separator: "_") + def followable_translation_key(follow) + follow.followable.class.name.parameterize(separator: "_") end end