通过重定向的气泡通知
我的场景:
在我的控制器中,确认用户后,我重定向到根目录(登陆页面:statics#landing
)并附上通知:
redirect_to root_url, notice: 'Confirmation successful.'
但在那里,我总是检查用户是否已经登录,如果是,我将他重定向到实际索引:
def landing
redirect_to actual_index_url if (user.signed_in?)
end
如何将确认通知传播到最后一页?
My scenario:
In my controller, after confirming the user, I redirect to root (a landing page: statics#landing
) and I attach a notice:
redirect_to root_url, notice: 'Confirmation successful.'
but there, I always check if the user is already signed in, and if so I'm redirecting him to the actual index:
def landing
redirect_to actual_index_url if (user.signed_in?)
end
How can I propagate the confirmation notice to the last page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为您正在寻找
flash.keep
。http://railsapi.com/doc/ Rails-v3.0.8rc1/classes/ActionDispatch/Flash/FlashHash.html#M006014
I think you're looking for
flash.keep
.http://railsapi.com/doc/rails-v3.0.8rc1/classes/ActionDispatch/Flash/FlashHash.html#M006014
尝试:
Try:
flash.keep(:notice)
- 如果您只想保留通知,只需flash.keep
将同时保留:notices
和:错误
。flash.keep(:notice)
- if you want to keep only notices justflash.keep
will keep both:notices
and:errors
.