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.
精彩评论