I would like to use Sanitize in my ruby app. I'm working with a few friends on this project, so making sure the code works when they git it is important too.
Anyways, on the console I did
>gem install nokogiri
Building native extensions.
This could take a while...
Successfully installed nokogiri-1.4.2
1 gem installed
Installing ri documentation for nokogiri-1.4.2...
Installing RDoc documentation for nokogiri-1.4.2...
>gem install
Successfully installed sanitize-1.2.1
1 gem installed
Installing ri documentation for sanitize-1.2.1...
Installing RDoc documentation for sanitize-1.2.1...
then in comment.rb
require 'rubygems'
require 'sanitize'
class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic=>true
belongs_to :user
before_validation :sanitize_data
def sanitize_data
Sanitize.clean(message)
end
end
but now, in any time I need to load comments on anything, I get
no such file to load -- sanitize
UPDATE:
I've also tried adding the following to my environment.rb
Rails::Initializer.run do |config|
config.gem 'nokogiri', :version => '~> 1.4.1', :source => 'http://gems.github.com'
end
gem 'nokogiri', '~> 1.4.1'
require 'nokogiri'
Rails::Initializer.run do |config|
config.gem 'sanitize', :version => '~> 1.2.1', :source => 'http://gems.github.com'
end
gem 'sanitize', '~> 1.2.1'
require 'sanitize'
and then running
>rake gems:install
and then getting rid of the 'requires' in comment.rb but whenever a comment gets saved, I get the following error
uninitialized constant Comment::Sanitize
What am I doing wrong? What is the best way to do what I am trying to do?