18F/micropurchase

View on GitHub
app/controllers/api/v0/bids_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
class Api::V0::BidsController < ApiController
  before_filter :require_authentication, except: [:index]
  skip_before_action :verify_authenticity_token

  def create
    @bid = PlaceBid.new(params: params, bidder: current_user, via: via)

    if @bid.perform
      render json: @bid.bid, serializer: BidSerializer
    else
      render json: { error: @bid.errors.full_messages.to_sentence }, status: 403
    end
  end
end