Skip to content

Commit

Permalink
Merge pull request #14 from tsheporamantso/add-place
Browse files Browse the repository at this point in the history
Add Place Back-End πŸ‘¨β€πŸ’»
  • Loading branch information
tsheporamantso authored Mar 1, 2024
2 parents bca1206 + 97498dc commit 0779aa8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/controllers/api/v1/places_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ def show
render json: @place
end

def new
@place = Place.new
render json: @place
end

# POST /places
def create
@place = Place.new(place_params)

if @place.save
render json: @place, status: :created, location: @place
render json: @place, status: :created
else
render json: @place.errors, status: :unprocessable_entity
end
Expand Down Expand Up @@ -46,6 +51,6 @@ def set_place

# Only allow a list of trusted parameters through.
def place_params
params.require(:place).permit(:description, :photo, :location, :rate, :user_id)
params.require(:place).permit(:description, :photo, :location, :rate, :user_id, :address)
end
end

0 comments on commit 0779aa8

Please sign in to comment.