Rails - 如何使用github的插件(如何安装,使用等) [英] Rails - how to use a plugin from github (how to install, utilize, etc)

查看:293
本文介绍了Rails - 如何使用github的插件(如何安装,使用等)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图为我的rails 3应用安装几个不同的插件。我cd到'/ vendor / plugins /',然后键入 git clone the_git_src_url

I'm trying to install a couple of different plugins for my rails 3 app. I cd to '/vendor/plugins/', then type git clone the_git_src_url.

我看到/ vendor / plugins /目录中的文件。然而,当我尝试使用插件提供的任何标签时,我都会得到

I see the files in the /vendor/plugins/ directory. However when I try to use any of the tags provided by the plugin I get

uninitialized constant ContentsController::HTMLToTextileParser

PriceTag html2textile 是我尝试使用的两个插件。这是触发上述错误的原因:<%= PriceTag.html_to_textile(@ content.desc)%>

PriceTag and html2textile are the two plugins I'm trying to use. This is what triggers the error above: <%= PriceTag.html_to_textile(@content.desc) %>

我正在开发中,我尝试重新启动服务器。有什么我失踪?

I'm working in development, I've tried to restart the server. Is there something I'm missing?

推荐答案

html2textile 是一个Ruby宝石,而不是Rails插件。要安装在Rails 3应用程序中使用的gem,您可以使用builder在Gemfile中添加新的gem。

html2textile is a Ruby gem, not a Rails plugin. To install a gem to be used in a Rails 3 app you can use builder adding the new gem in your Gemfile.

gem 'yourgem', :git=>'git://yourpath.git'

ie

gem 'html2textile', :git=>'git://github.com/thickpaddy/html2textile.git'

这表示您的应用程序需要该gem才能工作;运行 bundle install 将检查您的应用程序所需的所有gem是否已安装,并将安装缺少的宝石。

This will say that your application needs that gem to work; running bundle install will check if all the gems needed by your app are installed and will install the missing ones.

如果您喜欢手动操作,并且通常的 gem install yourgem 不可用,您可以安装它检查

If you like manual labor and the gem of your interest is not available with the usual gem install yourgem, you can install it checking out the source code from the repository and building the gem by yourself.

构建 html2textile

$ git clone https://github.com/thickpaddy/html2textile.git
$ cd html2textile/
$ gem build html2textile.gemspec
$ gem install html2textile-1.0.0.jgp.gem
$ gem list | grep html2
html2textile (1.0.0.jgp)

现在您可以要求 html2textile 在您的Rails应用程序或您的普通Ruby脚本中。

Now you can require html2textile in you Rails app or in your plain Ruby scripts.

$ irb
> require 'rubygems'
=> true
> require 'html2textile'
=> true

pricetag 可以在相同的情况下处理方式。

pricetag can be handled in the same way.

这篇关于Rails - 如何使用github的插件(如何安装,使用等)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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