Rails - 闪存通知中的数据太多

时间:2014-12-26 15:51:15

标签: ruby-on-rails flash

我有一个闪存通知导致cookie溢出错误:

candidates = Hiring::Candidate.find(params[:candidate_ids])
notice     = render_to_string(partial: '/hiring/candidates/new_candidates_assigned',    locals: {candidate: candidates})

redirect_to path, notice: notice

我想这是因为很多对象都传递给了flash。这怎么可以避免?

1 个答案:

答案 0 :(得分:1)

只需设置要在控制器中显示的信息

即可
redirect_to path, :notice => "Successfully assigned new candidate"

在视图中渲染部分并将闪光通知作为本地传递。

<%= render partial => '/hiring/candidates/new_candidates_assigned', :locals => {:flash_notice => flash[:notice]}%>