flash

  • Rails的消息提示有notice, alert,其实还可以追加类型.

    class ApplicationController < ActionController::Base
    add_flash_types :warning, :success, :danger
    end
  • notice的区别

# 1. 新建失败时,可以
 render 'new', flash.now[:notice] = '嘻嘻嘻'
# 2. 新建成功时,可以
redirect_to xx_path, flash['notice']= '嘻嘻嘻'

Last updated