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
function share_associations에는 @product_category 및 product_category_was 매개 변수가 있습니다. 문제는, 예를 들어 product_category_was.send ('images')를 호출하면 (호출이 동적이기 때문에 send를 사용하여 호출해야 함) 분명히 연결된 최신 이미지가 아닌 연결된 이미지를 가져옵니다. 어쨌든 내가 만든 객체가 그 시점에 연결된 이미지를 얻을 수 있습니까? 내가 생각레일즈 3의 컨트롤러에서 before_save 값을 얻으려면 어떻게해야합니까?
구체적으로 말하십시오 – Hitesh
아마도 당신이하고있는 일을 이해하기 위해 모델 코드를 볼 필요가 있습니다. –