开发者

flash[:notice] or flash.notice?

开发者 https://www.devze.com 2023-02-05 21:27 出处:网络
FlashHash has convenience methods for :notice and :alert. My question then is, which is most appropriate? flash[:notice] or flash.notice? Is it simply a mater of taste or this there a compelling reaso

FlashHash has convenience methods for :notice and :alert. My question then is, which is most appropriate? flash[:notice] or flash.notice? Is it simply a mater of taste or this there a compelling reason to chose one method o开发者_如何学Pythonver the other?


# File actionpack/lib/action_dispatch/middleware/flash.rb, line 150
150:       def notice
151:         self[:notice]
152:       end

I knew it!


Is it simply a mater of taste or this there a compelling reason to chose one method over the other?

Pretty much. flash[:notice] is how Rails handles it internally, so if there's a "right" way to do it, that's probably it. Personally, I prefer flash.notice, but that's just my own preference.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号