Forum: Ruby ERB question

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.
8d5bac396c79513d3c14008928936c1a?d=identicon&s=25 Robert D. La Gesse (Guest)
on 2006-03-16 18:06
(Received via mailing list)
Can anyone tell me what the difference is in these two statements?  Yes,
I'm a newbie!

<%=h device.send(column.name) %>

<%= device.send(column.name) %>

Specifically, what is the <%=h supposed to do?  The "h" doesn't appear
to do anything that I can find, yet RoR generates code using it...

Thanks much!

Rob
2c617cb11048884a0d46635c3c11f396?d=identicon&s=25 Markus Werner (Guest)
on 2006-03-16 18:09
(Received via mailing list)
Robert D. La Gesse wrote:
> Thanks much!
>
> Rob

h is a short form for is a short form for the method html_escape.

So IMHO it's more clear to write something like
<%= h(device.send(column.name)) %>


cu

polarix
9358cc96c46055cd68d4a76a9aefe026?d=identicon&s=25 Daniel Harple (Guest)
on 2006-03-16 18:12
(Received via mailing list)
On Mar 16, 2006, at 6:03 PM, Robert D. La Gesse wrote:

>
> Thanks much!
>
> Rob

See: http://wiki.rubyonrails.com/rails/pages/HowToEscapeHTML

RoR has it's own mailing list: http://rubyonrails.com/community

-- Daniel
8d5bac396c79513d3c14008928936c1a?d=identicon&s=25 Robert D. La Gesse (Guest)
on 2006-03-16 18:15
(Received via mailing list)
Markus Werner wrote:
>>
> cu
>
> polarix
>
OK, I guess that's clear enough... but it doesn't actually seem to make
any difference if the "h" is in there or not.  And I can't seem to
determine why Ruby on Rails sometimes generates code with the "h", and
sometimes it doesn't :)

Thank,

Rob
4299e35bacef054df40583da2d51edea?d=identicon&s=25 James Gray (bbazzarrakk)
on 2006-03-16 18:21
(Received via mailing list)
On Mar 16, 2006, at 11:13 AM, Robert D. La Gesse wrote:

>>> Specifically, what is the <%=h supposed to do?  The "h" doesn't
>> polarix
> OK, I guess that's clear enough... but it doesn't actually seem to
> make any difference if the "h" is in there or not.  And I can't
> seem to determine why Ruby on Rails sometimes generates code with
> the "h", and sometimes it doesn't :)

Try:

<%= h "< & >" %>

and:

<%= "< & >" %>

James Edward Gray II
This topic is locked and can not be replied to.