【发布时间】:2017-03-06 06:21:58
【问题描述】:
我希望有一种清洁方法可以让 Flash 消息在使用 React 的 ajax 调用中工作。一直是looking on the web,老实说,我确信无需添加太多代码就可以完成。
def my_method
[...]
flash[:success] = "Yea bouy."
if request.xhr?
render :json => {
:order => true,
}
end
end
我没有进行页面重定向,我想知道如何让一个简单的 Flash 显示出来。围绕显示添加更多方法的答案。我可以在我的方法中包含闪存代码吗?比如:
def my_method
[...]
if request.xhr?
render :json => {
:order => true,
}
end
return flash[:success] = "Yea bouy." # Only works when page refreshes.
end
【问题讨论】:
标签: ruby-on-rails ajax reactjs