diff --git a/app/controllers/boosts_controller.rb b/app/controllers/boosts_controller.rb index 5786f75a6..7489c92f6 100644 --- a/app/controllers/boosts_controller.rb +++ b/app/controllers/boosts_controller.rb @@ -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 diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 2bec3eb9f..a8cc4ad15 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -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 diff --git a/app/controllers/concerns/bubble_scoped.rb b/app/controllers/concerns/bubble_scoped.rb new file mode 100644 index 000000000..a03a01ddf --- /dev/null +++ b/app/controllers/concerns/bubble_scoped.rb @@ -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