Class: Spree::AuctionsController
- Inherits:
-
StoreController
- Object
- StoreController
- Spree::AuctionsController
- Defined in:
- app/controllers/spree/auctions_controller.rb
Instance Method Summary collapse
- #ending_soon ⇒ Object
- #index ⇒ Object
- #recently_completed ⇒ Object
- #show ⇒ Object
- #starting_soon ⇒ Object
- #vote_count ⇒ Object
- #vote_down ⇒ Object
- #vote_up ⇒ Object
Instance Method Details
#ending_soon ⇒ Object
15 16 17 18 |
# File 'app/controllers/spree/auctions_controller.rb', line 15 def ending_soon @auctions = Spree::Auction.incomplete.ending_soon render :index end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/spree/auctions_controller.rb', line 6 def index @auctions = Spree::Auction.in_progress.incomplete.current_end_datetime_ascending end |
#recently_completed ⇒ Object
20 21 22 23 |
# File 'app/controllers/spree/auctions_controller.rb', line 20 def recently_completed @auctions = Spree::Auction.recently_completed render :index end |
#show ⇒ Object
25 26 27 28 29 |
# File 'app/controllers/spree/auctions_controller.rb', line 25 def show @auction = Spree::Auction.find(params[:id]) @product = @auction.product @product_properties = @product.product_properties.includes(:property) end |
#starting_soon ⇒ Object
10 11 12 13 |
# File 'app/controllers/spree/auctions_controller.rb', line 10 def starting_soon @auctions = Spree::Auction.incomplete.starting_soon.starting_datetime_ascending render :index end |
#vote_count ⇒ Object
31 32 33 34 35 |
# File 'app/controllers/spree/auctions_controller.rb', line 31 def vote_count auction = Spree::Auction.find_by(id: params[:auction_id]) votes = auction.cached_votes_up render json: { votes: votes } end |
#vote_down ⇒ Object
45 46 47 48 49 50 51 |
# File 'app/controllers/spree/auctions_controller.rb', line 45 def vote_down auction = Spree::Auction.find_by(id: params[:auction_id]) user = Spree::User.find_by(id: params[:user_id]) auction.downvote_from user votes = auction.cached_votes_up render json: { votes: votes, voted_for: 0 } end |
#vote_up ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/controllers/spree/auctions_controller.rb', line 37 def vote_up auction = Spree::Auction.find_by(id: params[:auction_id]) user = Spree::User.find_by(id: params[:user_id]) auction.liked_by user votes = auction.cached_votes_up render json: { votes: votes, voted_for: 1 } end |