Forum: Ruby on Rails How do ASP Response.Write in RoR?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4c1eaa228c74856babe8a895a093a500?d=identicon&s=25 Peter Alvin (remoteportal)
on 2008-11-08 20:57
With Microsnot technology you an do this:

<% Response.Write "Hello, World" %>

How do you output text to the browser with Ruby?

Pete
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-11-08 21:02
(Received via mailing list)
On 8 Nov 2008, at 19:57, Peter Alvin <rails-mailing-list@andreas-
s.net> wrote:

>
> With Microsnot technology you an do this:
>
> <% Response.Write "Hello, World" %>
>
<%= "hello world" %>

Fred
4c1eaa228c74856babe8a895a093a500?d=identicon&s=25 Peter Alvin (remoteportal)
on 2008-11-09 01:27
Thanks Fred, that's perfect.

Pete
46f52c33235283752423837b91c581dd?d=identicon&s=25 Norm (Guest)
on 2008-11-09 18:25
(Received via mailing list)
Frederick Cheung wrote:
>
> Fred
>
>> How do you output text to the browser with Ruby?
>>
>> Pete
>> --
>> Posted via http://www.ruby-forum.com/.
>>
>>
Fred..
Maybe I am missing something here but why would you surround a straight
string in <%=""%>.  Why not just put hello world?

Norm
F05df05d7e52f4ad93cd0f9027818c75?d=identicon&s=25 gaveeno (Guest)
on 2008-11-09 18:35
(Received via mailing list)
the <%=  %> notation is what you use in a view to execute embedded
ruby code.  if you literally want to just print "hello world" in your
view, then you wouldn't need the <%=  %>.  however, say you want to
say "hello username" where username is the current user's name, then
your view would look something like:

hello <%=  currentuser.name %>
F05df05d7e52f4ad93cd0f9027818c75?d=identicon&s=25 gaveeno (Guest)
on 2008-11-09 18:38
(Received via mailing list)
one quick note... <%=  %> is what you use to executed embedded ruby
code and then display the output in your view.  <%  %> (no equals
sign) is what you use to just execute ruby code without displaying the
output in your view.  so you could do something like:

<% 3.times do  %>
Hello <%=  currentuser.name %>
<% end  %>
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-11-09 20:50
(Received via mailing list)
On 9 Nov 2008, at 17:24, Norm wrote:

>> <%= "hello world" %>
> Fred..
> Maybe I am missing something here but why would you surround a
> straight string in <%=""%>.  Why not just put hello world?
>
You wouldn't normally, just as you wouldn't actually put <%
Response.Write "Hello, World" %> either. It was an example.

Fred
This topic is locked and can not be replied to.