代码之家  ›  专栏  ›  技术社区  ›  Mike Sutton

Ruby需求问题

  •  0
  • Mike Sutton  · 技术社区  · 16 年前

    require 'rubygems'
    require 'sanitize'
    

    我得到错误:

    MissingSourceFile 
    no such file to load -- sanitize
    RAILS_ROOT: C:/Ruby/GWS
    
    (stack trace)
    
    This error occurred while loading the following files:
       sanitize
    

    更新: error while installing ruby gem

    2 回复  |  直到 8 年前
        1
  •  1
  •   Mike Sutton    16 年前

    Rails::Initializer.run do |config|
      config.gem 'nokogiri', :version => '~> 1.3.3', :source => 'http://gems.github.com'
    end
    
    gem 'nokogiri', '~> 1.3.3'
    
    require 'nokogiri'
    
    Rails::Initializer.run do |config|
      config.gem 'sanitize', :version => '~> 1.1.0', :source => 'http://gems.github.com'
    end
    
    gem 'sanitize', '~> 1.1.0'
    
    require 'sanitize'
    

    然后运行

    rake gems:install
    

        2
  •  0
  •   ehsanul    16 年前

    如果这不起作用,你可以随时尝试出售消毒液,看看效果如何。在命令行中:

    cd C:/myapp/vendor
    gem unpack sanitize
    

    然后在您的应用程序中:

    require 'vendor/sanitize/lib/sanitize'
    

    当然,根据不同的目录命名/结构调整上述内容。

    推荐文章