Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

169
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda