开发者

How to use ruby libraries in rails?

I just installed a ruby gem

 gem install anemone

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

Cheers


In your Gemfile add:

gem 'anemone'

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.


You must put used libraries into Gemfile. Everything about gemfiles is available on Bundler page.


There's an official Rails guide about this topic.


You also need to use 'require' and the name of the library on top of the file where you want to use the library. For example if you are using nokogiri you would need to add the line require 'nokogiri'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜