简体   繁体   English

如何在Rails网站上使用Ruby gem?

[英]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.

相关问题 Ruby on Rails:我如何使用Gem? (真空亚马逊API) - Ruby on Rails: How do I use a Gem? (Vacuum Amazon API) 使用Bloggy gem在Rails站点中的Jekyll博客:在每个构建中,如何在博客中使用Rails CSS? - Jekyll blog in Rails site using Bloggy gem: how do I use the Rails css for the blog, on each build? 如何将Rails动作或控制器名称插入到Ruby Gem中以在日志文件中使用? - How can I pull in the Rails action or controller names into my Ruby Gem for use in a log file? 如何运行使用Rails模型的Ruby任务? - How do I run Ruby tasks that use my Rails models? 如何获得Rails中包含的已安装红宝石宝石? - How do I get an installed ruby gem included in Rails? 如何为Windows上的Ruby on Rails安装json gem? - How do i install json gem for Ruby on Rails for Windows? Ruby on Rails 2.3.8:我如何需要特定版本的gem? - Ruby on Rails 2.3.8: How do I require a specifc version of a gem? 如何在Ruby on Rails中使用Evernote gem创建注释? - How do I create a note using the Evernote gem in Ruby on Rails? 我需要 gem 用户可以在 rails 站点上为我的 ruby​​ 投票 - I need gem were user can vote for my ruby on rails site 如何在Ruby on Rails支持的站点上设置两个用户之间的共享会话? - How do I setup a shared session between two users on my Ruby on Rails powered site?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM