Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
NameError: uninitialized constant Crawler::ScraperService on rails c

I'm trying to run a class on rails c for debug in a Rails project - duh - but I keep getting name error messages:

#app/services/scraper_service.rb

module Crawler
  class ScraperService
    URL_HOST = 'http://quotes.toscrape.com/page/1/'
    
    def initialize(tag)
      @tag = tag
    end

    def self.get_url
      agent = Mechanize.new
      binding.pry
      page = agent.get(URL_HOST)
    end     
  end
end

When I try to instance the class on rails c, I get this:

> Crawler::ScraperService.new('love').get_url
NameError: uninitialized constant Crawler::ScraperService
from (pry):5:in `<main>'

Or without the initialize method (of course, in this case it's out of the code):

> Crawler::ScraperService.get_url
NameError: uninitialized constant Crawler::ScraperService
from (pry):7:in `<main>'

I know it's a little thing, but I'm trying to understand this.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Oh, yes. Better never forget the "::" before this kind of call.

Right way:

::Crawler::ScraperService.get_url with the two :: before all the classes.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!