def update
@product_category = @business_category.product_categories.find(params[:id])
product_category_was = @business_category.product_categories.find(params[:id])
respond_to do |format|
if @product_category.update_attributes(params[:product_category])
share_associations(@product_category, product_category_was) if in_params('_maps_attributes', 'product_category')
format.js
format.html { redirect_to(admin_product_categories_path, :notice => 'Product category was successfully updated.') }
format.xml { head :ok }
else
format.js
format.html { render :action => "edit" }
format.xml { render :xml => @product_category.errors, :status => :unprocessable_entity }
end
end
end
函數share_associations具有參數@product_category和product_category_was。問題是,當我打電話給product_category_was.send('圖像')例如(我必須使用發送調用,因爲調用是動態的),它顯然會拉出最新的相關圖像,而不是相關的圖像。無論如何,我可以讓對象獲得與它製作時相關的圖像嗎?如何在Rails 3中的控制器中獲得before_save值?
請具體 – Hitesh 2011-05-13 07:25:57
可能需要查看模型代碼以瞭解您在做什麼。 – 2011-05-13 08:46:02