简体   繁体   中英

Ruby on Rails: where to put the 'require' files?

I'm trying to use this gem barometer and in the document it says that it can be used right out of the box with using require 'barometer'

I've always used gems and put them in the gemfile , but I think this is different...

Do I just download this entire repo, and copy all the files in the lib folder into my vendor folder? or maybe public folder?

Where would you typically put these files? And where would you include the require ? Should this be in the application controller ? Or maybe in the helper? Sorry for this really noob question.

I know in my local environment, I can just type in gem install barometer in my console, and not have to put in a require , but I don't think this will work in heroku, or production environment.

I've always used gems and put them in the gemfile, but I think this is different...

No, this is no different. Barometer is a Rubygem and putting it in your Gemfile is exactly the way to use it.

As with every library, your require should go in whichever file uses the code, for example the same file that the Barometer.new call is. You don't always need the require line depending on your Ruby environment, but it's always a good idea to get used to it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM