Rails 中行为不当的 db:seed
我的数据库种子出现了一些奇怪的行为。有问题的代码是这样的:
#seeding info about Question Types
@question_types = [:name=> "Single Input", :name=> "Multiple Choice"]
@question_types.each do |question_type|
new_question_type = QuestionType.find_or_create_by_name(:name => question_type[:name]);
end
rake db:seed 运行良好,但是当我查看 Question_types 表时,我发现只创建了“多项选择”,没有“单输入”的迹象
我尝试删除我的数据库并从但它仍然在发生。我正在使用 Rails 2.3.5 和 PostgreSQL 数据库
I've got some strange behaviour going on with my DB Seed. the piece of code in question is this:
#seeding info about Question Types
@question_types = [:name=> "Single Input", :name=> "Multiple Choice"]
@question_types.each do |question_type|
new_question_type = QuestionType.find_or_create_by_name(:name => question_type[:name]);
end
rake db:seed runs fine but when I look in the question_types table I find that only "Multiple Choice" has been created, no sign of "Single Input"
I tried deleting my DB and starting from scratch but it's still happening. I'm using Rails 2.3.5 and a PostgreSQL database
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了!
这是一个语法问题......
而不是:
我需要:
Found it!
It was a syntax issue...
instead of:
I needed: