Simplify passing parameters in FollowsController
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user