concat

concat(string)
Instance Public methods

The preferred method of outputting text in your views is to use the <%= âtextâ %> eRuby syntax. The regular puts and print methods do not operate as expected in an eRuby code block. If you absolutely must output text within a non-output code block (i.e., <% %>), you can use the concat method.

1
2
3
4
5
6
7
8
9
10
11
<%
    concat "hello"
    # is the equivalent of <%= "hello" %>
 
    if logged_in
      concat "Logged in!"
    else
      concat link_to('login', action: :login)
    end
    # will either display "Logged in!" or a login link
%>
doc_ruby_on_rails
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.