Skip to content

Instantly share code, notes, and snippets.

@Fire-Dragon-DoL
Created February 10, 2013 22:35
Show Gist options
  • Save Fire-Dragon-DoL/4751352 to your computer and use it in GitHub Desktop.
Save Fire-Dragon-DoL/4751352 to your computer and use it in GitHub Desktop.
# POST /offers
# POST /offers.json
def create
@offer = Offer.new(offer_params)
@offer.offer_timestamp = Time.zone.now
@offer.user = current_user
respond_to do |format|
if @offer.save
format.html { redirect_to [@offer.product, @offer], notice: 'Offer was successfully created.' }
format.json { render json: @offer, status: :created, location: [@offer.product, @offer] }
else
# This looks ugly
@product = @offer.product
@offers = @product.offers
format.html { render action: :index }
format.json { render json: @offer.errors, status: :unprocessable_entity }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment