After upgrading to rails 3.2 I see ActiveRecord::Fixture::FormatError: a YAML error occurred parsing

╄→尐↘猪︶ㄣ 提交于 2019-12-11 15:04:33

问题


I see the following error after upgrading to rails 3.2.12 with ruby 1.9.2.

ActiveRecord::Fixture::FormatError: a YAML error occurred parsing /SampelRails/user_properties.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Please have a look at http://www.yaml.org/faq.html The exact error was: Psych::SyntaxError: couldn't parse YAML at line 1 column 0

I have doubled checked the yml files and they seem to be indented properly.

according to https://github.com/rails/rails/issues/2731 this issue seem to be fixed in rails 3.1.1.


回答1:


just experienced the same issue but the problem was that i was saving my VCR cassettes in test/fixtures/vcr_cassettes/*.yml.
ActiveRecord::Fixture gets confused by yml files with content other than AR fixture data.




回答2:


The link posted by nathanvda really worked.

Try adding this at the beginning of config/boot.rb

require 'yaml'
YAML::ENGINE.yamler= 'syck'

Rails 3 - 'Couldn't parse Yaml'




回答3:


I just had the same issue. Solved it by removing a dummy fixture file from fixtures directory. That file had nothing but comments in it.



来源:https://stackoverflow.com/questions/15406670/after-upgrading-to-rails-3-2-i-see-activerecordfixtureformaterror-a-yaml-er

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!