简体   繁体   中英

How do I use a Ruby gem on my Rails site?

I'm working on a Rails web site ( https://github.com/jhsu802701/dvi ) called Doppler Value Investing that uses my very first Ruby gem (dvi_scraper, source code at https://github.com/jhsu802701/dvi_scraper ). dvi_scraper downloads and processes financial statements from publicly traded companies, and dvi shows the results. The results are saved in a Postgres database and in a *.csv file.

I added dvi_scraper to the Gemfile for my Rails app, and I used "bundle install" to install it. However, the scripts and files from dvi_scraper DO NOT show up in the dvi directory where I'm working on my Rails site. Instead, they're all at /home/(my username)/.rvm/gems/ruby-2.0.0-p195/gems/dvi_scraper-0.0.0 . And the Dvi_scraper.dopeler command doesn't work in my dvi app.

What do I need to do to get the files from dvi_scraper to show up in my dvi app? As you might guess, I don't really understand how RubyGems and Gemfile work even though I've used them.

This is the expected behavior. The gem files are automatically included (typically) when added via the Gemfile.

From the console

rails console

Try running

require_or_load 'dvi_scraper'

This should return true if the gem is properly installed

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