1
在IE中測試時,我遇到了Rails 4.2.1和Ruby 2.1應用程序的幾個問題。如果我將某些內容保存到數據庫並執行重定向,則這些值將在數據庫中保存兩次。在IE中的Rails問題 - 在數據庫中雙重存儲
有沒有人有這個呢?
保存了Methode在控制器:
if request.post?
@question.attributes = params[:question]
if @question.save
flash.now[:notice] = t("flash.saved")
update_answers params
redirect_after_save @question
end
end
def update_answers params
if !params[:add].nil?
params[:add].each do | id, data |
answer = Answer.new
data[:question_id] = @question.id
answer.update_attributes data
end
end
end
def redirect_after_save q
if params[:action_after_save] == 'back'
flash[:notice] = I18n.t("flash.saved")
redirect_to :controller => :lessons, :action => :edit, :id => q.lesson_id
end
if params[:action_after_save] == 'new'
flash[:notice] = I18n.t("flash.saved")
redirect_to :action => :new, :id => q.lesson_id
end
if params[:action_after_save] == 'test'
flash[:notice] = I18n.t("flash.saved")
redirect_to :action => :test, :id => q.id
end
end
我沒有使用turbolinks
。
查看代碼:
<%= f.submit t("main.save"), :icon => :save %>
<%= t("question.or_save_and") %>:
<% [[t('question.after_save_back'), 'back'],
[t('question.after_save_new'), 'new'],
[t('question.test_question'), 'test']].each do |it| %>
<%= f.submit(it.first, :disable_with => "saving",
:onclick => "$('#edit_question').append('<input type=\"hidden\" name=\"action_after_save\" value=\"" + it.second + "\" />');",
:icon => :save) %>
<% end %>
這是被保存時調用的代碼。
def multiple_choice
@question = Question.find params[:id]
return false unless check_authorization @question
add_edit_breadcrumbs @question
if request.post?
@question.attributes = params[:question]
if @question.save
flash.now[:notice] = t("flash.saved")
SLACKNOTIFIER.ping "Bevor update answers"
update_answers params
SLACKNOTIFIER.ping "After update answers"
redirect_after_save @question
end
end
end
整個代碼在IE調用兩次......
根據日誌,請求是否也做了兩次?什麼版本的IE? – eirikir
是它的兩倍。它的所有同樣的道理都是一樣的。在邊緣很好。 – Felix
您能否也請在您的視圖中顯示相關的代碼?當然是 – panmari