Hi everyone, I am a newbie to RoR. I installed the Instant Rails package 1.7, and with scaffold, I was able to create and connect to a database. However, when I embed some code in rhtml(list.rhtml in the tutorial there), it does not display in browser. I can see the html part on the screen without problem, but the ruby part does not get processed at all. When I try a simple rhtml file such as below, <html> <head> <title>All Recipes</title> </head> <body> <ul> <li>Addition: <% print "World!" %> </li> </ul> <h1>Online Cookbook - All Recipes</h1> </body> </html> all I can see is Addition: Online Cookbook. I think this has something to do with eruby or erb, but do not know how to proceed. Any help would be much appreciated! Thanks Shrikant -- 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 -~----------~----~----~----~------~----~------~--~---
On 3 Jan 2009, at 00:02, Shrikant Sv wrote:> > Hi everyone, > > I am a newbie to RoR. I installed the Instant Rails package 1.7, and > with scaffold, I was able to create and connect to a database. > However, when I embed some code in rhtml(list.rhtml in the tutorial > there), it does not display in browser. I can see the html part on the > screen without problem, but the ruby part does not get processed at > all. > When I try a simple rhtml file such as below, ><% puts ... %> or <% print ...%> achieves very little (at best it will output to your server''s log file). You need to be using <%= which inserts the result of evaluating it''s contents, ie <%= Time.now %> Fred> <html> > <head> > <title>All Recipes</title> > </head> > <body> > <ul> > <li>Addition: <% print "World!" %> </li> > </ul> > <h1>Online Cookbook - All Recipes</h1> > </body> > </html> > > all I can see is > Addition: > Online Cookbook. > > I think this has something to do with eruby or erb, but do not know > how > to proceed. > > Any help would be much appreciated! > > Thanks > Shrikant > -- > 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 -~----------~----~----~----~------~----~------~--~---
Shrikant, <% %> is code that is executed, but not displayed in the browser. <%= %> is code that will be executed and displayed. Hope that helps! Ethan Gunderson On Fri, Jan 2, 2009 at 6:02 PM, Shrikant Sv <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi everyone, > > I am a newbie to RoR. I installed the Instant Rails package 1.7, and > with scaffold, I was able to create and connect to a database. > However, when I embed some code in rhtml(list.rhtml in the tutorial > there), it does not display in browser. I can see the html part on the > screen without problem, but the ruby part does not get processed at all. > When I try a simple rhtml file such as below, > > <html> > <head> > <title>All Recipes</title> > </head> > <body> > <ul> > <li>Addition: <% print "World!" %> </li> > </ul> > <h1>Online Cookbook - All Recipes</h1> > </body> > </html> > > all I can see is > Addition: > Online Cookbook. > > I think this has something to do with eruby or erb, but do not know how > to proceed. > > Any help would be much appreciated! > > Thanks > Shrikant > -- > 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 -~----------~----~----~----~------~----~------~--~---
Just an example of both usages <% if is_admin? do %> <h1><%= admin_title %></h1> <% end %> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---