Load a custom file in Rails

Source: Internet
Author: User

Rails generates the Lib folder by default, but there is no default load file in lib, you can configure the following code in the CONFIG/APPLICATION.RB to load the module or class defined in the Lib folder:

Config.autoload_paths + =%W (#{config.root}/lib)

Of course, this is not just a way to load Lib files, but also to load other custom folders.

Note that these custom files of the module or class name must be and file name always, such as the class name AppStore, the file name must be APP_STORE.RB, which is also rails in the Convention is greater than the configuration.

Load a custom file in Rails

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.