def purchase
...
perform_payment_post
redirect_to :action => 'billing'
...
end
def perform_payment_post
params[:coverages] ||= {}
params[:customer][:coverage_addon] = (params[:coverages].collect { |k,v| k }).join(', ')
params[:customer][:coverage_ends_at] = 1.year.from_now
Rails.logger.info("--- id = #{cookies.signed[:incomplete_gaq_customer_id]}")
id = cookies.signed[:incomplete_gaq_customer_id]
return redirect_to :action => @is_affiliate_user ? 'affiliate':'quote' if id.nil?
@customer = Customer.find(cookies.signed[:incomplete_gaq_customer_id])
return redirect_to :action => 'please_call' if @customer.status_id != 0
@customer.update_attributes(params[:customer])
@customer.notes.create({ :notes_text => @note }) if @note
if params[:property_id].to_i == 0 then @customer.properties.create(params[:property]) end
end
在线购买方法出现错误redirect_to:action => "计费"
AbstractController::DoubleRenderError: Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".
请帮助我。
答案 0 :(得分:0)
如果你想早点在控制器中返回,你需要像这样写
redirect_to(:action => @is_affiliate_user ? 'affiliate':'quote') and return if id.nil?