我在我的控制器下面的代碼:Rails在編輯記錄和創建時發送事件?
# GET /kases/1/edit
def edit
@kase = Kase.find(params[:id])
respond_to do |format|
format.html { render :layout => 'kaseshow'} # show.html.erb
format.xml { render :xml => @kase }
format.pdf { render :layout => false }
end
end
# POST /kases
# POST /kases.xml
def create
@company = Company.find(params[:kase][:company_id])
@kase = @company.kases.new(params[:kase])
if @kase.save
UserMailer.deliver_makeakase("[email protected]", "Highrise", @kase) if params[:sendtohighrise]
UserMailer.deliver_makeakaseteam("[email protected]", "Highrise", @kase) if params[:notify_team_of_creation]
@kase.create_freeagent_project(current_user) if params[:send_to_freeagent]
redirect_to(@kase)
#flash[:notice] = 'Case was successfully created.'
flash[:notice] = fading_flash_message("Case was successfully created.", 5)
else
render :new
end
end
我試圖使它所以如果用戶編輯的情況下,然後選擇發送到希捷FreeAgent tickbox:
@kase.create_freeagent_project(current_user) if params[:send_to_freeagent]
那麼情況對於Freeagent(在線會計軟件)感到不滿。我並不擔心重複處理,因爲如果情況已經存在於Freeagent中,那麼用戶不需要重新發送它。
這可能嗎?