Created
February 10, 2013 22:35
-
-
Save Fire-Dragon-DoL/4751352 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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