C
C
Ciscoridze2014-09-05 14:28:48
Ruby on Rails
Ciscoridze, 2014-09-05 14:28:48

What module and class filenames to use in Rails?

Good afternoon. It was required to connect the class to the web application. To do this, I added the line config.autoload_paths += %W( #{Rails.root}/app/services ) to the config/application.rb file. But the class stubbornly refused to be included until I renamed it from "someclass.rb" to "some_class.rb". What's the matter? Is it some sort of configuration convention or what?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vsuhachev, 2014-09-05
@Ciscoridze

You are right, this is such an agreement in rails, autoloading.
For example, when you refer to the MyModule::MyClass class, rails looks for my_module/my_class.rb in all folders specified in config.autoload_paths and if the file is found, then require.
By default, autoload_paths already contains all subdirectories of the app directory, that is, in your case, config/application.rb does not need to be edited

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question