flyerhzm / rails_best_practices

a code metric tool for rails projects
http://rails-bestpractices.com
MIT License
4.16k stars 276 forks source link

Idea: check Rails flash.new vs. flash #307

Open david-a-wheeler opened 6 years ago

david-a-wheeler commented 6 years ago

Here's an enhancement idea.

In Rails, flash.now should never end up with redirect_to, and flash (without .now) should normally not end up at "render". However, it's not that hard to make that mistake, especially after making other changes. I think it'd be useful for rails_best_practices to detect that case.

E.g., detect misuses like this:

      flash.now[:danger] = t('admin_only')
      redirect_to '/'