我正在尝试创建Ruby脚本以在我的Rails 3环境中运行。
但是,每当我使用Rails Runner运行此 rubyscript 时,都会收到此错误:
require 'rubygems'
require 'json'
@payload = {
"message" => "helloworld",
"station" => {"id"=>12345}
}.to_json
puts @payload
错误:
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/dependencies.rb:212:in `require': no such file to load -- json (LoadError)
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/dependencies.rb:212:in `require'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/dependencies.rb:198:in `load_dependency'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/dependencies.rb:554:in `new_constants_in'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/dependencies.rb:198:in `load_dependency'
from /usr/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta4/lib/active_support/dependencies.rb:212:in `require'
from createflags.rb:2
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.0.beta4/lib/rails/commands.rb:39:in `eval'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.0.beta4/lib/rails/commands/runner.rb:47
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.0.beta4/lib/rails/commands.rb:39:in `require'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.0.beta4/lib/rails/commands.rb:39
from script/rails:6:in `require'
from script/rails:6
有人可以告诉我我能做些什么来解决这个问题吗?