Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7181863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:38:48+00:00 2026-05-28T17:38:48+00:00

Ok this may seem stupid and I have googled extensively using various different keywords

  • 0

Ok this may seem stupid and I have googled extensively using various different keywords and terms, attempted a lot of various different methods and tried to my very last breadth and cannot seem to figure out how to do this. All I want is stdout in a rails app without needing to break my block.

Currently, when I do a block of ruby code in my rails app and want to output the value I do the following

<% somearray do | item | %>
    <%= item %>
<% end %>

To me this is quite messy, I know coming from a PHP background it’s not how one should imagine how to code in rails but coming from many different environments I like my code to look nice to me. It’s very easy to encapsulate every single line with <% %> but I’d prefer my code to be my code and my mark up to be my mark up.

What I’d like, but which doesn’t work, is….

<%
    somearray do | item |
        whatever item #whatever being puts or similar
    end
%>

It’s solely for the aesthetics of the code and not for what it produces but for me, a very long time programmer, it means a lot and a lot of time saved when trying to see where and when code blocks begin and end.

Thanks in advance,

Jay (c0ld)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:38:49+00:00Added an answer on May 28, 2026 at 5:38 pm

    You can use concat. From the docs:

    The preferred method of outputting text in your views is to use the <%= “text” %> eRuby syntax. …. If you absolutely must output text within a non-output code block (i.e., <% %>), you can use the concat method.

    Examples

    <%
        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
    %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this may seem like a stupid question but I have a query string which
This question may seem stupid, but, so be it! I have a stupid problem
This may seem like a stupid Question but i have two cubes being rendered
This question may seem completely stupid, but say i have a PHP page with
This may seem like a stupid question, so here goes: Other than parsing the
This may seem like a stupid question, but what message do i send to
Ok, this may seem like a stupid question (for Flash Developers) but I really
this may seem like a stupid question, but it is stumping me nontheless. I'm
This may seem like a basic/stupid/obviously-answered question, but I wanted to check: why use
This may seem like a stupid question, but I need to know where the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.