Ruby on Rails : uninitialized constant (NameError)

41 Views Asked by At

I am completely new to Ruby on Rails and I have to migrate an application from Ruby 1.9.2 and Rails 3.0.3 to Ruby 3.0.0 and Rails 7.1.2.

I copied my old application structure to a new directory of a new server and when I run "rails server", it throws me this error : uninitialized constant Tools (NameError)

This error is located in the file config/initializers/config.rb where I have this line of code : RESSOURCE = Tools.get_param

I found that I have a tools.rb file in my app/helpers directory and that inside this file I had the folllowing :

class Tools

  def Tools.get_param ()
    affichage = Hash.new   
    fic =File.open("config/Ressource.txt",'r')
    fic.each_line do |ligne|        #lecture ligne à ligne
      ligne = ligne.chomp
      word = ligne.split("|") #lecture de chaque mot d'une ligne
      affichage [word[0]] = word[1]
    end
    return affichage
  end

...

What is missing to Rails for it to find my Tools class ?

0

There are 0 best solutions below