如何在 HTML 环境中使用 Ruby 中的固定装置的嵌套 upto 循环?
我正在准备一个数据库,由于反复试验的原因,该数据库被删除并一遍又一遍地迁移。为了节省创建数据库条目的时间,我使用了固定装置。
我的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
感谢您的帮助!
I am preparing a db which for reasons of trial and error is dropped and migrated over and over. In order to save time on creating db-entries I have made use fixtures.
My fixture.yml code looks like this:
<% 1.upto(n) do |i|
1.upto(m) do |j|
distance: <%= 1+rand(998) %>
quantity: <%= 0 %>
end
end %>
For each connection between i and j I want to introduce a random distance and a zero transportation quantity, as it will be optimized by GAMS anyway. How can I make that work?
These are the error messages I get:
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
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您不处于 erb 模式时,请关闭您的 erb 标签。
Close your erb tags when you aren't in erb mode.