diff --git a/app/controllers/api/v1/puzzles_controller.rb b/app/controllers/api/v1/puzzles_controller.rb index 3ba2337..4e5507b 100644 --- a/app/controllers/api/v1/puzzles_controller.rb +++ b/app/controllers/api/v1/puzzles_controller.rb @@ -1,16 +1,16 @@ class Api::V1::PuzzlesController < ApplicationController skip_before_action :set_current_user, only: [:index] + before_action :find_puzzles, only: [:index] def index - find_puzzles(params[:zip_code]) raise NoPuzzlesFoundException if @puzzles_in_zip_code.empty? render json: PuzzleSerializer.new(@puzzles_in_zip_code) end private - def find_puzzles(zip_code) - @puzzles_in_zip_code = Puzzle.find_by_zip_code(zip_code) + def find_puzzles + @puzzles_in_zip_code = Puzzle.find_by_zip_code(params[:zip_code]) end end