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?
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
.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’
%>.
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.