【发布时间】:2012-09-26 18:44:53
【问题描述】:
我有一个应用程序,其中包含调用。我希望能够取消通话并提供取消通话的原因。到目前为止,我的取消操作在控制器中工作,但我试图弄清楚如何扩展它,以便在它发布“取消”到 call_status 字段之前,它还将根据下降填充 cancel_reason 字段下来。
这是我目前所拥有的:
查看代码: 取消按钮
<%= link_to 'Cancel',
cancel_call_path(call),
confirm: 'Are you sure you want to cancel the call?',
:method => :post,
:class => 'btn btn-danger btn-mini' %>
控制器代码:取消操作
def cancel
@call = Call.find(params[:id])
attrs = {
call_status: 'cancel',
incharge_id: @call.units.first.incharge_id,
attendant_id: @call.units.first.attendant_id
}
attrs.merge!({ incharge2_id: @call.units.second.incharge_id, attendant2_id: @call.units.second.attendant_id }) if @call.units.count == 2
if @call.update_attributes(attrs)
@call.units.each do |unit|
CallMailer.cancel_call(unit.incharge, @call).deliver
CallMailer.cancel_call(unit.attendant, @call).deliver
end
redirect_to calls_url, :notice => "Call was successfully cancelled"
else
redirect_to calls_url, :error => "Whoops."
end
end
我想要显示的确认弹出窗口,以及取消的原因,或者 取消操作 与带有小表单的不同视图相关联,其中包含一个原因。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 cancellation