3

I'm learning rails 5.0. When I learn Ruby, I know that ruby file name can be different with class name inside. But when I move to rails, I see that ruby file name and class name must have same format. For example, a class name CheckInDetail will be in check_in_detail.ruby. I also see that the module name must be matched with directory name. For example, module authentication must be inside authentication directory. Some example for my conclusion is:

  1. rspec: class name must base on file name.
  2. grape: class name must base on file name. Also module name must be matched with directory.

If I don't follow those convention, when compiling rails will throw exception. I don't see those conventions on those library github pages. Will this true for whole rail project, with all libraries ?

Trần Kim Dự
  • 5,872
  • 12
  • 55
  • 107

1 Answers1

7

With rails there is a convention how you should define classes and file names. A class named ManageOrder should reside inside a file named manage_order.rb. This is a standard convention that rails follows otherwise rails won't be able to load the class.

Pragash
  • 713
  • 7
  • 9