Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BE | Refactor PuzzlesController#index Endpoint #70

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/controllers/api/v1/puzzles_controller.rb
Original file line number Diff line number Diff line change
@@ -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

Expand Down