Pattern: Use of flash
before render
in Rails controller
Issue: -
Using flash
assignment before render
in Rails controllers will persist the message for too long.
# bad
class HomeController < ApplicationController
def create
flash[:alert] = "msg"
render :index
end
end
# good
class HomeController < ApplicationController
def create
flash.now[:alert] = "msg"
render :index
end
end