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