Extract BubbleScoped

This commit is contained in:
Jeffrey Hardy
2024-09-13 18:44:18 -04:00
parent 85f49fe3cb
commit 7f45b8fe6e
3 changed files with 14 additions and 11 deletions
+1 -6
View File
@@ -1,5 +1,5 @@
class BoostsController < ApplicationController
before_action :set_bubble
include BubbleScoped
def index
end
@@ -10,9 +10,4 @@ class BoostsController < ApplicationController
def create
@bubble.boosts.create!
end
private
def set_bubble
@bubble = Bubble.find(params[:bubble_id])
end
end
+1 -5
View File
@@ -1,5 +1,5 @@
class CommentsController < ApplicationController
before_action :set_bubble
include BubbleScoped
def create
@bubble.comments.create!(comment_params)
@@ -10,8 +10,4 @@ class CommentsController < ApplicationController
def comment_params
params.require(:comment).permit(:body)
end
def set_bubble
@bubble = Bubble.find(params[:bubble_id])
end
end
+12
View File
@@ -0,0 +1,12 @@
module BubbleScoped
extend ActiveSupport::Concern
included do
before_action :set_bubble
end
private
def set_bubble
@bubble = Bubble.find(params[:bubble_id])
end
end