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

  • Home
  • SEARCH
  • 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 6105081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:54:59+00:00 2026-05-23T13:54:59+00:00

While it could of course be done neater by putting the code into the

  • 0

While it could of course be done neater by putting the code into the controller or something, I can not image why the following is happening:
assume that @some_table.some_text contains 5 lines.
putting the following code in my html.erb file:

<% @some_table.some_text.lines.each do |cur_line| %>
    foo
<% end %>

results in 5 foos followed by all the lines in @some_table.some_text.
I could imagine this would happen when using the <%= %> but not with <% %>.
Obviously, I don’t want the @some_table.some_text to be shown.

What am I doing wrong here?

  • 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-23T13:55:00+00:00Added an answer on May 23, 2026 at 1:55 pm

    That’s just the way that the Ruby lines method works – it returns an Enumerable, which can’t be looped through in the same way. For your purposes, try

    <% @some_table.some_text.split(/\n/).each do |cur_line| %>
    

    instead.

    Alternatively convert the Enemerable into an array before calling each, using one of the methods, eg:

    <% @some_table.some_text.lines.collect.each do |cur_line| %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could you guys please tell me how I can make the following code more
I am wondering if something like this could be done(of course what I have
a while ago i could comment any code in php with netbeans like this:
Can I upload content(any type png/jpg) onto android market, which I could download while
How could I, on the fly, remove spaces entered into a textbox while the
I know the following code could extract whole texts of the docx document, however,
After a while I figured out I could bind Shark to the process of
A while ago, I saw on a Screencast a tool that could be ran
I am having huge lines data which could accomdate in Textbox. While I am
While I realize that I could just show the form off-screen and hide it,

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.