Ruby MIME :: Multipart错误

时间:2015-05-15 14:54:30

标签: ruby mime-types

这是我安装的宝石 哑剧(0.4.2) 哑剧型(2.5) 模仿(0.2.1) multipart-post(2.0.0)

尝试执行命令在我的控制台中创建新的多部分mime时

@msg = MIME::Multipart::Mixed.new

我收到这些错误。

NameError: uninitialized constant MIME::Multipart
    from /home/user1/.rvm/gems/ruby-1.9.3-p547@project/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:466:in `rescue in load_missing_constant'
    from /home/user1/.rvm/gems/ruby-1.9.3-p547@project/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:462:in `load_missing_constant'
    from /home/user1/.rvm/gems/ruby-1.9.3-p547@project/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:106:in `const_missing_with_dependencies'
    from /home/user1/.rvm/gems/ruby-1.9.3-p547@project/gems/mime-types-2.5/lib/mime.rb:40:in `const_missing'
    from (irb):7
    from /home/user1/.rvm/rubies/ruby-1.9.3-p547/bin/irb:12:in `<main>'

1 个答案:

答案 0 :(得分:0)

安装宝石只是它的一部分,你需要先使用它才能使用它。

require 'mime'

刚尝试过:

2.2.0 :001 > require 'mime'
 => true 
2.2.0 :002 > msg = MIME::Multipart::Mixed.new
 => #<MIME::Multipart::Mixed:0x007ff15c0e06f0 ...