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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:27:07+00:00 2026-05-16T18:27:07+00:00

I am actually using Rails 3.0, so it is rails console vs rails runner

  • 0

I am actually using Rails 3.0, so it is rails console vs rails runner try.rb. The following code runs well in the console but not as a script with runner. I need runner (instead of using ruby try.rb) because there are some ActiveRecord code for the project.

Update: I couldn’t run it inside of myproj\lib\tasks\ (when the current directory is myproj\lib\tasks\), but can run it inside of myproj, so the question becomes, why must it be run at myproj?

http_header = {'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.53 Safari/534.3'}

url = URI.parse('http://www.google.com/')

response = Net::HTTP.start(url.host, url.port) do |http|
  http.get(url.path, http_header)
end

puts response.body

The error code is:

c:\ror\proj\lib\tasks>rails runner try.rb
c:/ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.0/lib/rails/commands/runner.rb:50:in `eval': no method name given (ArgumentError)
        from c:/ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.0/lib/rails/commands/runner.rb:50:in `eval'
        from c:/ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.0/lib/rails/commands/runner.rb:50:in `<top (required)>'
        from c:/ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.0/lib/rails/commands.rb:39:in `require'
        from c:/ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.0/lib/rails/commands.rb:39:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'
  • 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-16T18:27:07+00:00Added an answer on May 16, 2026 at 6:27 pm

    Where are you running the command from?

    You need to run the command from your rails root directory and give a full or relative path to the filename so rails runner lib/try.rb

    The reason for this is that the command runner accepts either the name of a file containing ruby code or a string containing ruby code. When the command runner can not find the file named in argv(0) it tries to eval argv(0), so it is trying to eval the string try.rb

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

Sidebar

Related Questions

I'm new to Visual C# Studio (actually using the Express edition, but another developer
How do I do the following SQL in LINQ? I am actually using LINQ
I'm facing following problem actually: I'm using Spring with jQuery. I have Controller: @Controller
I'm still a newbie with Rails (and actually development period). I'm using Rails 3.
I'm pretty new to rails and it's the first time I'm actually using authlogic
Using Rails 2, I try to separate different, dynamic image sizes trough another Model
Hey guys, I'm having trouble understanding a Rails construct. I'm using Rails 3 but
I'm using a Rails blogging gem Enki on Heroku, but am having trouble posting
I'm using a remote form to submit comments in Rails. The user should not
I am actually using h:selectOneRadio to display items, given to it from f:selectItems tag.

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.