Rails Rails edge 支援 add_flash_types

xdite · July 09, 2012 · Last by chechaoyang replied at July 09, 2012 · 2445 hits

https://github.com/rails/rails/commit/238a4253bf229377b686bfcecc63dda2b59cff8f

以後可以在

class ApplicationController
   add_flash_types :error, :warning
end

然後使用

redirect_to root_path, :error => "no permission"

這種寫法了。

起因只是我在寫 bootstrap-helper 時,被還要寫 :flash => { :error => "no permission" }這種寫法搞毛了。所以拉了個 pull request。最後被其他 rails team member 改了個解法就支援了...

不過我也好奇了翻了一下 code。原始的 notice, alert 是 @dhh 大爺自己爽就加上去的。為什麼其他人反而不能因為高興就加上常見的 error, warning 呢?=_=

看起来不错

You need to Sign in before reply, if you don't have an account, please Sign up first.