Hi All, I upgrading my old rails application with new rails version 3.0.1 , In my old application i stored html tagged data(i.e <p> i am paragraph tagged word </p>) in database(i.e mysql) and i renderd the html tagged data in view means. The browser detect the html tag and generate the relevent view of data string (i.e i am paragraph tagged word) Controller: ========== @test=Text.find(1) View: === <div>Text from database: <span style="xxxx"><%=@test.word%> </span> Expected output in browser: ========================== Text from database: i am paragraph tagged word Note: It is working fine in rails 2.3.8 Result output in browser for rails 3.0.1: ======================================== Text from database: <p> i am paragraph tagged word </p> Why i didn''t get the html result generated output in rails 3.0.1 Corrector suggest me what went wrong ? Thanks in Advance, Jak. -- 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.
Frederick Cheung
2010-Nov-24 14:57 UTC
Re: rendering stored html tag from database to view
On Nov 24, 2:47 pm, Arun Kumar <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi All, > > I upgrading my old rails application with new rails version 3.0.1 , In > my old application i stored html tagged data(i.e <p> i am paragraph > tagged word </p>) in database(i.e mysql) and i renderd the html tagged > data in view means. The browser detect the html tag and generate the > relevent view of data string (i.e i am paragraph tagged word) > > Controller: > ==========> @test=Text.find(1) > > View: > ===> <div>Text from database: <span style="xxxx"><%...@test.word%> </span> > > Expected output in browser: > ==========================> Text from database: i am paragraph tagged word > Note: It is working fine in rails 2.3.8 > > Result output in browser for rails 3.0.1: > ========================================> Text from database: <p> i am paragraph tagged word </p> > > Why i didn''t get the html result generated output in rails 3.0.1 > Corrector suggest me what went wrong ? >Rails escapes your html for you these days, and by default it will assume that a piece of text of unknown provenance is not safe and so will escape it. You can either use the raw view helper or call html_safe on the string itself, ie <%= raw some_method_returning_html %> or <% some_method_returning_html.html_safe %> Fred> Thanks in Advance, > Jak. > > -- > 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.
Frederick Cheung wrote in post #963584:> On Nov 24, 2:47pm, Arun Kumar <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> @test=Text.find(1) >> Result output in browser for rails 3.0.1: >> ========================================>> Text from database: <p> i am paragraph tagged word </p> >> >> Why i didn''t get the html result generated output in rails 3.0.1 >> Corrector suggest me what went wrong ? >> > Rails escapes your html for you these days, and by default it will > assume that a piece of text of unknown provenance is not safe and so > will escape it. > You can either use the raw view helper or call html_safe on the string > itself, ie > > <%= raw some_method_returning_html %> or <% > some_method_returning_html.html_safe %> > > FredThanks for the quick reply, It works fine for me, Jak -- 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.