Flash.now, why not just use an instance variable instead?

Hi, me again with another silly question. If flash.now only lasts for
the request on which it was set, what makes it different than a plain
old instance variable?

Wouldn’t,

def action
@message = “message”
end
<%= @message %>

produce the same results as,

def action
flash.now[“message”] = “message”
end
<%= flash[“message”] %>

?

the assumption is that the flash is in your layout and flash.now will
behave the same

Ah, of course.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs