我正在准备一个db,由于试验和错误的原因,它被反复删除和迁移。为了节省创建db-entries的时间,我已经使用了fixtures。
我的fixture.yml代码如下所示:
<% 1.upto(n) do |i|
1.upto(m) do |j|
distance: <%= 1+rand(998) %>
quantity: <%= 0 %>
end
end %>
对于i和j之间的每个连接,我想引入随机距离和零运输量,因为它将由GAMS优化。我怎样才能做到这一点?
这些是我收到的错误消息:
rake aborted!
(erb):5: syntax error, unexpected ':', expecting keyword_end
distance: <%= 1+rand(998) ; _erbout.concat "\n quan: "
^
(erb):5: unterminated string meets end of file
感谢您的帮助!
答案 0 :(得分:0)
当您处于erb模式时关闭erb标签。
<% 1.upto(n) do |i|
1.upto(m) do |j| %>
distance: <%= 1+rand(998) %>
quantity: <%= 0 %>
<% end
end %>