Writing To The Response in Rails? (Like “echo” in PHP)

前端 未结 4 1634
小鲜肉
小鲜肉 2021-02-07 08:37

I know that I can do this in Rails:

<%=\"hello\" %>

but is there any way to do this

<%
echo \"hello\"
%>

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-07 09:00

    You're looking for "print" or "puts", depending on whether or not you want a newline (probably not). Almost every object implements .to_s, which works also, though my feeling is that there's probably a better way to do whatever you're trying to do. Any more context on this?

提交回复
热议问题