Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Lelievre-david committed Dec 19, 2024
1 parent ff51f7b commit 5f8011a
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions app/controllers/api/v1/requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def create
end

def update
if @request.update(update_request_params)
plant_attributes_from_params(@request)
if @request.update(request_params)
render json: @request.to_blueprint, status: :ok
else
render_validation_error(@request)
Expand Down Expand Up @@ -106,19 +107,12 @@ def set_request

def request_params
params.permit(
:plant_stage_id, :name, :plant_name, :plant_stage_name, :quantity, :due_date,
:plant_stage_id, :name, :quantity, :due_date,
:comment, :temperature, :photoperiod, :requester_first_name, :requester_last_name,
:requester_email, :laboratory
)
end

def update_request_params
params.permit(
:plant_stage_id, :name, :plant_name, :plant_stage_name,
:quantity, :due_date, :temperature, :photoperiod
)
end

def plant_attributes_from_params(request)
return if request_params[:plant_stage_id].blank?

Expand Down

0 comments on commit 5f8011a

Please sign in to comment.