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 7030843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:43:30+00:00 2026-05-28T00:43:30+00:00

I have a model connected to a log, so I’m beginning to build ways

  • 0

I have a model connected to a log, so I’m beginning to build ways to use that info with the model and pass it around elsewhere.

this method:

  def read_log
    counter = 1 
    f = File.open(self.log_file_path, 'r')
    while (line = f.gets)
      puts "#{counter}: #{line}"
      counter = counter + 1
    end
  end

works, and dumps the log to the command line but ends with nil, so it reads it out to stdout but when calling that I get nothing. How can I read the contents into a more useful format? I need to read this into a controller variable for a template within rails on a webpage. It is basic, but something I haven’t done yet.

  • 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-28T00:43:30+00:00Added an answer on May 28, 2026 at 12:43 am
    contents = f.read
    

    Now contents contains… the contents. Not sure what “useful” means in your context, but you can do things like split on newline to get each line.

    You can also create an enumerator via f.lines, whether or not that’s more useful, not sure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have model Article it has field title with some text that may contain
In my controller I have model operations that can return empty results. I've setup
I have an express app that I want to use the connect-form module on
I have a simple url that will toggle one field in my search model.
I have a join model that connects Authors to Products. It's called contracts. I
I have build a wcf web service that simply provides MS Dynamics SQL data
Here's what I need to do. I have a Tournament model, which is connected
I have a GSM modem connected via USB. The modem creates 2 serial ports.
Currently, I have an application that uses Firebird in embedded mode to connect to
I have model Foo which has field bar. The bar field should be unique,

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.