Review a generated order update

from Ruby on Rails
Rails 8.1.3.1 / Ruby 4.0.6 advanced 6 min 3 issues to find

Review this generated controller against the task and identify three distinct production issues.

Update the quantity of one current-account order and return only its public ID, status, and quantity.

ruby
class OrdersController < ActionController::API
  def update
    order = current_account.orders.find(params[:id])
    attributes = params.require(:order).permit(:quantity)

    order.update(attributes)

    customer_names = Order.all.map do |candidate|
      candidate.customer.name
    end
    Rails.logger.info("customers=#{customer_names.join(',')}")

    render json: order.attributes
  end
end

generated code is illustrative, not from any one model

Open in playground
Report an error