I went through AWDwR and could not find one example where within your flash[:notice] you include a link inside the message as well. Is this frowned upon? If not anyone have any sample code how you would do this? Thanks... In Canada our long weekend was last weekend :-). John Kopanas john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org
To separate html out of my controller, instead of putting a link in flash[:notice], I would use a different variable in the flash and store the :controller and :action (and :id, if necessary) to what I want the view to link to: flash[:link] = { :controller => "/book", :action => "show", :id => @params[''id''] } Then in the view: <h3><%= @flash[:notice] %> <%= flash[:link] ? link_to "click here", flash[:link] : "" %></h3> Duane Johnson (canadaduane) On May 28, 2005, at 8:36 AM, John Kopanas wrote:> I went through AWDwR and could not find one example where within > your flash[:notice] you include a link inside the message as well. > Is this frowned upon? If not anyone have any sample code how you > would do this? > > Thanks... In Canada our long weekend was last weekend :-). > > John Kopanas > john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
I don''t seem to understand the following code: <%= flash[:link] ? link_to "click here", flash[:link] : "" %> It does not work plus I am not sure how Ruby handles it. Do you mind helping explain it and looking over it to see if it makes sense? On 28-May-05, at 11:01 AM, Duane Johnson wrote:> To separate html out of my controller, instead of putting a link in > flash[:notice], I would use a different variable in the flash and > store the :controller and :action (and :id, if necessary) to what I > want the view to link to: > > flash[:link] = { :controller => "/book", :action => "show", :id => > @params[''id''] } > > Then in the view: > > <h3><%= @flash[:notice] %> <%= flash[:link] ? link_to "click here", > flash[:link] : "" %></h3> > > Duane Johnson > (canadaduane) > > On May 28, 2005, at 8:36 AM, John Kopanas wrote: > > >> I went through AWDwR and could not find one example where within >> your flash[:notice] you include a link inside the message as >> well. Is this frowned upon? If not anyone have any sample code >> how you would do this? >> >> Thanks... In Canada our long weekend was last weekend :-). >> >> John Kopanas >> john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org >> >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
> I don''t seem to understand the following code: > > <%= flash[:link] ? link_to "click here", flash[:link] : "" %> > > It does not work plus I am not sure how Ruby handles it. Do you > mind helping explain it and looking over it to see if it makes sense?Sorry, Ruby probably needs parentheses around the link_to''s parameters. Try this instead: <%= flash[:link] ? link_to("click here", flash[:link]) : "" %> The ? is the ternary operator (borrowed from C) ... It is the equivalent of the following: <% if flash[:link] link_to("click here", flash[:link]) else "" end %> _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails