Skip to content

Instantly share code, notes, and snippets.

@mwhagedorn
Created December 15, 2009 20:08
Show Gist options
  • Save mwhagedorn/257255 to your computer and use it in GitHub Desktop.
Save mwhagedorn/257255 to your computer and use it in GitHub Desktop.
ProductDataController
#one method only used currently (rest to be deleted)
# POST /product_data
# POST /product_data.xml
def create
logger.info("POST /product_data")
@product_datum = ProductDatum.new(params[:product_datum])
if params[:product_datum][:uploaded_data].blank?
flash[:notice] = "You must select a file to upload."
redirect_to( :action => "new", :contract_id => params[:product_datum][:contract_id]) && return
elsif params[:product_datum][:contract_id].blank?
flash[:notice] = "You must select a contract for these products."
redirect_to( :action => "new") && return
end
@product_datum.save(:false)
@product_datum.after_spreadsheet_load
end
class ProductDatumLineItemController < ApplicationController
def update
@product_datum_line_item = ProductDatumLineItem.find(params[:id])
if @product_datum_line_item.update_attributes(params[:product_datum_line_item])
logger.debug "done"
else
redirect_to :action=>:fix, :id=> params[:id]
end
end
def fix
@product_datum_line_item = ProductDatumLineItem.find(params[:id])
@categories = @product_datum_line_item.product_datum.contract.contract_categories
@entities = @product_datum_line_item.product_datum.contract.contract_entities
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment