如何在 Rails 中使用 ruby​​ 库? [英] How to use ruby libraries in rails?

查看:40
本文介绍了如何在 Rails 中使用 ruby​​ 库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了一个 ruby​​ gem

I just installed a ruby gem

 gem install anemone

但我无法直接在我的 rails 应用程序中使用它,这是我第一次使用外部 ruby​​ 库,因此如果您能深入了解它而不仅仅是解决方案,这将非常有帮助

But I cannot hit off to use it directly in my rails application, this is the first time I'm using an external ruby library so it will be very helpful if you can give me an insight into it rather than just a solution

干杯

推荐答案

在你的 Gemfile 添加:

宝石'海葵'

这样 Rails 会在启动时加载库,然后你就可以使用它了.您甚至不必使用 require 关键字.

This way Rails will load the library when it starts, and you can then use it. You don't even have to use the require keyword.

这篇关于如何在 Rails 中使用 ruby​​ 库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆