How can one do something similar to:
redirect_to(:back, :notice => "Photo was successfully created. Click
<a href=''#{url_for artist_photo_path(@photo.artist,
@photo)}''>here</a>
to view it")
The flash notice message is shown however, it shows: "Photo was
successfully created. Click <a
href=''/artists/1/photos/39''>here</a> to
view it". It displays the anchor element as a string instead of an
html element
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Christian Fazzini wrote in post #957990:> How can one do something similar to: > > redirect_to(:back, :notice => "Photo was successfully created. Click > <a href=''#{url_for artist_photo_path(@photo.artist, @photo)}''>here</a> > to view it") > > The flash notice message is shown however, it shows: "Photo was > successfully created. Click <a href=''/artists/1/photos/39''>here</a> to > view it". It displays the anchor element as a string instead of an > html elementSo don''t escape the HTML! Easy. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Try this
class YourController < ApplicationController
include ActionView::Helpers::SanitizeHelper
def your_action
redirect_to(:back, :notice => sanitize("Photo was successfully
created. Click <a href=''#{url_for artist_photo_path(@photo.artist,
@photo)}''>here</a> to view it"))
end
end
If you haven''t used the sanitize method before, please read this
http://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html#method-i-sanitize
before using it.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Arailsdemo, I dont think the sanitize helper works in the controller level. I get the error: undefined method `sanitize Marnen, please be more specific! On Oct 31, 12:09 pm, "Arailsdemo A." <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Try this > > class YourController < ApplicationController > include ActionView::Helpers::SanitizeHelper > > def your_action > redirect_to(:back, :notice => sanitize("Photo was successfully > created. Click <a href=''#{url_for artist_photo_path(@photo.artist, > @photo)}''>here</a> to view it")) > end > end > > If you haven''t used the sanitize method before, please read thishttp://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.... > > before using it. > > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Nov 1, 11:50 am, Christian Fazzini <christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Arailsdemo, I dont think the sanitize helper works in the controller > level. I get the error: undefined method `sanitize > > Marnen, please be more specific! >Look at where you''re displaying the contents of the flash; you may need to either not call h() or use the raw helper to indicate that the contents of the flash are safe to display Fred> On Oct 31, 12:09 pm, "Arailsdemo A." <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > > > Try this > > > class YourController < ApplicationController > > include ActionView::Helpers::SanitizeHelper > > > def your_action > > redirect_to(:back, :notice => sanitize("Photo was successfully > > created. Click <a href=''#{url_for artist_photo_path(@photo.artist, > > @photo)}''>here</a> to view it")) > > end > > end > > > If you haven''t used the sanitize method before, please read thishttp://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.... > > > before using it. > > > -- > > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Maybe the better idea is just to use some session variable instead of flash? (just for cases like this one) On Oct 29, 12:33 pm, Christian Fazzini <christian.fazz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> How can one do something similar to: > > redirect_to(:back, :notice => "Photo was successfully created. Click > <a href=''#{url_for artist_photo_path(@photo.artist, @photo)}''>here</a> > to view it") > > The flash notice message is shown however, it shows: "Photo was > successfully created. Click <a href=''/artists/1/photos/39''>here</a> to > view it". It displays the anchor element as a string instead of an > html element-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Did you include the module? class YourController < ApplicationController include ActionView::Helpers::SanitizeHelper Christian Fazzini wrote in post #958461:> Arailsdemo, I dont think the sanitize helper works in the controller > level. I get the error: undefined method `sanitize > > Marnen, please be more specific!-- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.