I create a simple .rhtml file "hello.rhtml" in the "view" folder of the rails app. <html> <head> <title>Hello World</title> </head> <body> <p>Hello World!</p> <p><%= ''Hello Dynamic World'' %></p> </body> </html> The problem is when I run the web server and load the url "http://localhost:3000/say/hello", only "Hello World!" is shown, the second line ''Hello Dynamic World'' is gone? Anyone can help me? Thanks very very very much! -- Posted via http://www.ruby-forum.com/.
Marnen Laibow-Koser
2009-Oct-05 18:13 UTC
Re: Browser can''t display the ruby part in rhtml
Browny Lin wrote:> I create a simple .rhtml file "hello.rhtml" in the "view" folder of the > rails app. > > <html> > <head> > <title>Hello World</title> > </head> > <body> > <p>Hello World!</p> > <p><%= ''Hello Dynamic World'' %></p> > </body> > </html> > > The problem is when I run the web server and load the url > "http://localhost:3000/say/hello", only "Hello World!" is shown, the > second line ''Hello Dynamic World'' is gone? > > Anyone can help me? Thanks very very very much!What does your generated HTML look like? What''s in your application log? Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
Marnen Laibow-Koser
2009-Oct-05 18:15 UTC
Re: Browser can''t display the ruby part in rhtml
Marnen Laibow-Koser wrote:> Browny Lin wrote: >> I create a simple .rhtml file "hello.rhtml" in the "view" folder of the >> rails app.[...] Ack! Didn''t notice this when posting the first time around...if you''re using Rails 2.x, that should be hello.html.erb . If your tutorial is using the .rhtml extension, then it''s out of date and you should follow another tutorial. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=UTF-8" http-equiv="Content-Type"> <title></title> </head> <body bgcolor="#ffffff" text="#000000"> Marnen Laibow-Koser wrote: <blockquote cite="mid:787a4c22d2aa0d389a5aa90a966e53dd-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org" type="cite"> <pre wrap="">Marnen Laibow-Koser wrote: </pre> <blockquote type="cite"> <pre wrap="">Browny Lin wrote: </pre> <blockquote type="cite"> <pre wrap="">I create a simple .rhtml file "hello.rhtml" in the "view" folder of the rails app. </pre> </blockquote> </blockquote> <pre wrap=""><!---->[...] Ack! Didn''t notice this when posting the first time around...if you''re using Rails 2.x, that should be hello.html.erb . If your tutorial is using the .rhtml extension, then it''s out of date and you should follow another tutorial. Best, -- Marnen Laibow-Koser <a class="moz-txt-link-freetext" href="http://www.marnen.org">http://www.marnen.org</a> <a class="moz-txt-link-abbreviated" href="mailto:marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org">marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org</a> </pre> </blockquote> <font size="-1"><font face="Helvetica, Arial, sans-serif">.rhtml works fine at least through 2.2.2. .html.erb may be the way to go but .rhtml is not the problem. The problem is what do you expect a string to do? <%= %> says to evaluate the ruby expression and then return the result. I think the code should be something like <%= p ''whatever'' %>. <br> <br> Am I loosing my mind?<br> <br> Norm<br> </font></font> <br> --~--~---------~--~----~------------~-------~--~----~<br> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. <br> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en<br> -~----------~----~----~----~------~----~------~--~---<br> </body> </html> <br>
Thanks for your information, Marnen Laibow-Koser My rails is 2.3.4, I change the file "hello.rhtml" to "hello.html.erb" But the browser still just show the first line, and doesn''t show anything inside <%= XXX %>, do I miss something? Many many thanks again Marnen Laibow-Koser wrote:> Marnen Laibow-Koser wrote: >> Browny Lin wrote: >>> I create a simple .rhtml file "hello.rhtml" in the "view" folder of the >>> rails app. > [...] > > Ack! Didn''t notice this when posting the first time around...if you''re > using Rails 2.x, that should be hello.html.erb . If your tutorial is > using the .rhtml extension, then it''s out of date and you should follow > another tutorial. > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org-- Posted via http://www.ruby-forum.com/.
2009/10/6 Browny Lin <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > > Thanks for your information, Marnen Laibow-Koser > > My rails is 2.3.4, I change the file "hello.rhtml" to "hello.html.erb" > > But the browser still just show the first line, and doesn''t show > anything inside <%= XXX %>, do I miss something?Make sure you have not got any other files hello.* in the view folder (backup files for example). Some versions of Rails have been confused by these. Temporarily remove hello.html.erb and make sure that it then complains it cannot find the file. This will make sure it is picking up the right one. What does the generated html look like (View, Page Source or similar in browser)? Post the relevant section here. Colin> > Many many thanks again > > > > > Marnen Laibow-Koser wrote: >> Marnen Laibow-Koser wrote: >>> Browny Lin wrote: >>>> I create a simple .rhtml file "hello.rhtml" in the "view" folder of the >>>> rails app. >> [...] >> >> Ack! Didn''t notice this when posting the first time around...if you''re >> using Rails 2.x, that should be hello.html.erb . If your tutorial is >> using the .rhtml extension, then it''s out of date and you should follow >> another tutorial. >> >> Best, >> -- >> Marnen Laibow-Koser >> http://www.marnen.org >> marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > > -- > Posted via http://www.ruby-forum.com/. > > > >
It works !!! Thanks very very much for Colin ^^ I temporarily remove hello.html.erb and the browser show the error message "Missing template say/hello.erb in view path app/views" So I change file name to hello.erb, and the ruby code inside <%= %> works! Many thanks again Colin Law wrote:> 2009/10/6 Browny Lin <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>: >> >> >> Thanks for your information, Marnen Laibow-Koser >> >> My rails is 2.3.4, I change the file "hello.rhtml" to "hello.html.erb" >> >> But the browser still just show the first line, and doesn''t show >> anything inside <%= XXX %>, do I miss something? > > Make sure you have not got any other files hello.* in the view folder > (backup files for example). Some versions of Rails have been confused > by these. Temporarily remove hello.html.erb and make sure that it > then complains it cannot find the file. This will make sure it is > picking up the right one. > > What does the generated html look like (View, Page Source or similar > in browser)? Post the relevant section here. > > Colin-- Posted via http://www.ruby-forum.com/.
Marnen Laibow-Koser
2009-Oct-06 13:23 UTC
Re: Browser can''t display the ruby part in rhtml
Browny Lin wrote:> > It works !!! Thanks very very much for Colin ^^ > > I temporarily remove hello.html.erb and the browser show the error > message "Missing template say/hello.erb in view path app/views" > > So I change file name to hello.erb, and the ruby code inside <%= %> > works!Then you have a routing problem. What''s the output if you type "rake routes" at the command line?> > Many thanks again >Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
Hello, Marnen Laibow-Koser I run C:\Documents and Settings\brownylin\rails\my_app>rake routes and the results are shown below three lines: (in C:/Documents and Settings/brownylin/rails/my_app) /:controller/:action/:id /:controller/:action/:id(.:format) What does the routing problem mean? And what dose the three line output means? Many many thanks for Marnen Laibow-Koser ^^ Marnen Laibow-Koser wrote:> Browny Lin wrote: >> >> It works !!! Thanks very very much for Colin ^^ >> >> I temporarily remove hello.html.erb and the browser show the error >> message "Missing template say/hello.erb in view path app/views" >> >> So I change file name to hello.erb, and the ruby code inside <%= %> >> works! > > Then you have a routing problem. What''s the output if you type "rake > routes" at the command line? > >> >> Many thanks again >> > > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org-- Posted via http://www.ruby-forum.com/.
Marnen Laibow-Koser
2009-Oct-06 14:11 UTC
Re: Browser can''t display the ruby part in rhtml
Browny Lin wrote:> > Hello, Marnen Laibow-Koser > > I run C:\Documents and Settings\brownylin\rails\my_app>rake routes > > and the results are shown below three lines: > > (in C:/Documents and Settings/brownylin/rails/my_app) > /:controller/:action/:id > /:controller/:action/:id(.:format)OK, then that''s just the defaults. I''m not sure you''d be able to get say/hello to work with just these routes. I assume you have an action called hello in your SaysController class?> > What does the routing problem mean? And what dose the three line output > means?http://guides.rails.info/routing.html> > Many many thanks for Marnen Laibow-Koser ^^ >You''re welcome! Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.