views:

29

answers:

2

I use flash[:error] to display a simple message to users that they cannot do a delete operation under certain conditions. I also have a link that will help them to get information about the entity that they wanted to delete and why they cannot do so.

Is it advisable to include this hyperlink in the flash message? Which would mean that I would have a HTML fragment in my controller. If not, how would I go about doing this?

A: 

You can. You can add some Helper in your controller too.

Or you can do it by i18n system.

shingara
A: 

Hello,

the flash object is a holder for storing view fragments/messages and persist them for one redirection using the session. I see absolutely no problem in storing a link, or better an URL.

example :

redirect_to posts_path, :alert => "You cannot do that", :flash => { :url => post_path(@post) }

and in layout view, the usual suspects :

- if flash[:alert]
  ...
  - if flash[:url]
    = link_to "blah blah", flash[:url]
slainer68