[英]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 ). 我正在一个名为Doppler Value Investing的Rails网站( https://github.com/jhsu802701/dvi )上使用我的第一个Ruby gem(dvi_scraper,源代码位于https://github.com/jhsu802701/dvi_scraper )。 dvi_scraper downloads and processes financial statements from publicly traded companies, and dvi shows the results.
dvi_scraper从公开交易的公司下载并处理财务报表,而dvi显示结果。 The results are saved in a Postgres database and in a *.csv file.
结果保存在Postgres数据库和* .csv文件中。
I added dvi_scraper to the Gemfile for my Rails app, and I used "bundle install" to install it. 我将dvi_scraper添加到我的Rails应用程序的Gemfile中,并使用“捆绑安装”来安装它。 However, the scripts and files from dvi_scraper DO NOT show up in the dvi directory where I'm working on my Rails site.
但是,dvi_scraper中的脚本和文件不会显示在我在Rails站点上工作的dvi目录中。 Instead, they're all at /home/(my username)/.rvm/gems/ruby-2.0.0-p195/gems/dvi_scraper-0.0.0 .
相反,它们都位于/ home /(我的用户名)/。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.
而且Dvi_scraper.dopeler命令在我的dvi应用程序中不起作用。
What do I need to do to get the files from dvi_scraper to show up in my dvi app? 我需要怎么做才能从dvi_scraper中获取文件以显示在dvi应用程序中? As you might guess, I don't really understand how RubyGems and Gemfile work even though I've used them.
您可能会猜到,即使我使用了RubyGems和Gemfile,我也不是很了解。
This is the expected behavior. 这是预期的行为。 The gem files are automatically included (typically) when added via the Gemfile.
通过Gemfile添加时,通常会自动包含gem文件。
From the console 从控制台
rails console
Try running 尝试跑步
require_or_load 'dvi_scraper'
This should return true if the gem is properly installed 如果正确安装了gem,则应返回true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.