Flash [: notice] or flash.notice?

FlashHash has convenient methods for: notifications and: warnings. Then my question is which is most appropriate? flash [: notice] or flash.notice? Is it just a mater of taste, or does it have a good reason to choose one method over another?

+3
source share
2 answers
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 150
150:       def notice
151:         self[:notice]
152:       end

I knew it!

+3
source

Is it just a mater of taste, or does it have a good reason to choose one method over another?

To a large extent. flash[:notice]is how Rails handles it internally, so if there is a โ€œrightโ€ way to do it, maybe it is. Personally, I prefer flash.notice, but this is only my preference.

+2
source

Source: https://habr.com/ru/post/1787055/


All Articles