Class: Spree::BidsController

Inherits:
StoreController
  • Object
show all
Defined in:
app/controllers/spree/bids_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/spree/bids_controller.rb', line 17

def create
  @auction = Spree::Auction.find(params[:auction_id])
  if spree_current_user
    @bid = Spree::Bid.create(auction: @auction, bidder: spree_current_user, amount: params[:amount])
    @recorded_bid, message = @auction.receive_bid(@bid)
    if @recorded_bid
      flash[:success] = message
    else
      flash[:error] = message
    end
  else
    flash[:error] = Spree.t("must_be_signed_in_to_bid")
  end
  redirect_to auction_path @auction
end

#indexObject



2
3
4
5
# File 'app/controllers/spree/bids_controller.rb', line 2

def index
  @auction = Spree::Auction.find(params[:auction_id])
  @bids = @auction.visible_bids_in_chron_order
end

#newObject



7
8
9
10
11
12
13
14
15
# File 'app/controllers/spree/bids_controller.rb', line 7

def new
  @auction = Spree::Auction.find(params[:auction_id])
  if spree_current_user
    @bid = Spree::Bid.new(auction: @auction)
  else
    flash[:error] = Spree.t("must_be_signed_in_to_bid")
    redirect_to auction_path @auction
  end
end