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
.
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 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
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'
i.e.
gem 'html2textile', :git=>'git://github.com/thickpaddy/html2textile.git'
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.
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.
To build 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)
Now you can require html2textile
in you Rails app or in your plain Ruby scripts.
$ irb
> require 'rubygems'
=> true
> require 'html2textile'
=> true
pricetag
can be handled in the same way.
You should be using bundler with rails3. Add this to your Gemfile:
gem 'html2textile', :git=>'git://github.com/thickpaddy/html2textile.git'
then
bundle install
lbz is right about html2textile.
Other plugins are installed as follows:
Rails2:
script/plugin install <source>
Rails3:
rails plugin install <source>
<source>
would normally be sth. like git://github.com/xxx/yyy.git
精彩评论