rails中 flash 和 flash.now的区别

时间:2023-01-13 00:09:04

Flash[:notice]’s message will persist to the next action and should be used when redirecting to another action via the ‘redirect_to’ method.

flash方法的消息会从保存到下一个action,和redirct_to方法一起使用

Flash.now[:notice]’s message will be displayed in the view your are rendering via the ‘render’ method.

flash.now 方法的详细只会在当前视图显示,不会保存到下一个action,和render方法一起使用