hello I''m new to RoR and i have concern regarding on how to output a string with a value that parse on it. Example in php: $value = 1; $string = ''the value is ''.$value.''.''; and it gives you the output which is: "the value is 1." so how we are going to do it in RoR. Any help would be appreciated. I know its very simple to the one who knows it. Forgive me im only a newbie. Thank you! -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Johnroy World wrote:> hello I''m new to RoR and i have concern regarding on how to output a > string with a value that parse on it. > > Example in php: > $value = 1; > $string = ''the value is ''.$value.''.''; > > and it gives you the output which is: "the value is 1." so how we are > going to do it in RoR. Any help would be appreciated. I know its very > simple to the one who knows it. Forgive me im only a newbie. Thank you!myvalue = 1 mystring = ''the value is '' + myvalue.to_s + ''.'' Cheers, Darrik -- Darrik Mazey Developer DMT Programming, LLC. P.O. Box 91 Torrington, CT 06790 office: 330.983.9941 fax: 330.983.9942 mobile: 330.808.2025 darrik-hYmAEBE3lWIoJ/VrfD3uVNBPR1lH4CV8@public.gmane.org To obtain my public key, send an email to darrik-3ZOItiUs85ODFug2jf9dzoDEJ8dgO5X3FNOCUTQkUI4@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Or use interpolation with double-quotes: myvalue = 1 mystring = "the value is #{myvalue.to_s}." -- Josh http://iammrjoshua.com Darrik Mazey wrote:> Johnroy World wrote: >> hello I''m new to RoR and i have concern regarding on how to output a >> string with a value that parse on it. >> >> Example in php: >> $value = 1; >> $string = ''the value is ''.$value.''.''; >> >> and it gives you the output which is: "the value is 1." so how we are >> going to do it in RoR. Any help would be appreciated. I know its very >> simple to the one who knows it. Forgive me im only a newbie. Thank you! > > myvalue = 1 > mystring = ''the value is '' + myvalue.to_s + ''.'' > > Cheers, > Darrik > > -- > Darrik Mazey > Developer > DMT Programming, LLC. > P.O. Box 91 > Torrington, CT 06790 > office: 330.983.9941 > fax: 330.983.9942 > mobile: 330.808.2025 > darrik-hYmAEBE3lWIoJ/VrfD3uVNBPR1lH4CV8@public.gmane.org > > To obtain my public key, send an email to > darrik-3ZOItiUs85ODFug2jf9dzoDEJ8dgO5X3FNOCUTQkUI4@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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
<% value = 1 %> The value is <%= value %> Read the getting started guide on http://guides.rubyonrails.com and that will teach you a lot On 04/02/2009, at 16:07, Johnroy World <rails-mailing-list@andreas- s.net> wrote:> > hello I''m new to RoR and i have concern regarding on how to output a > string with a value that parse on it. > > Example in php: > $value = 1; > $string = ''the value is ''.$value.''.''; > > and it gives you the output which is: "the value is 1." so how we are > going to do it in RoR. Any help would be appreciated. I know its very > simple to the one who knows it. Forgive me im only a newbie. Thank > you! > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ryan Bigg wrote:> <% value = 1 %> > The value is <%= value %>or <% value = 1 %> The value is <%= h(value) %> In case you don''t trust the "value" of value. The h (http_escape) method will help protect you against injection attacks. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Robert Walker wrote:> The value is <%= h(value) %>Oops! Previous post was a bad example. Assume value was taken from user input, which in that case you should escape it to make it safe. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---