当我开始使用rails时,如何摆脱此警告/错误。
在没有:safe选项的情况下调用'load' - 默认为安全模式。
=> Booting Thin
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Called 'load' without the :safe option -- defaulting to safe mode.
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3001, CTRL+C to stop
答案 0 :(得分:3)
当某些代码在没有配置safe_yaml gem的情况下调用YAML.load方法时,该消息来自safe_yaml gem。
有几种方法可以摆脱警告。
配置safe_yaml以禁止警告:
SafeYAML::OPTIONS[:suppress_warnings] = true
明确配置safe_yaml的默认模式:
SafeYAML::OPTIONS[:default_mode] = :safe
如果您是调用YAML.load的人,则在调用YAML.load时显式传递:safe选项或调用YAML.safe_load / YAML.unsafe_load:
YAML.load(yaml, :safe => true)
YAML.load(yaml, :safe => false)
YAML.safe_load(yaml)
YAML.unsafe_load(yaml)