我的应用程序在localhost中工作正常,但是当我部署到heroku并尝试创建新订单时,我收到此错误:
2013-03-20T21:26:02+00:00 app[web.1]: Started GET "/orders/new" for 189.44.29.3 at 2013-03-20 21:26:02 +0000
2013-03-20T21:26:02+00:00 app[web.1]: Processing by OrdersController#new as HTML
2013-03-20T21:26:02+00:00 app[web.1]: Rendered orders/new.html.erb within layouts/application (49.4ms)
2013-03-20T21:26:02+00:00 app[web.1]: Completed 500 Internal Server Error in 62ms
2013-03-20T21:26:02+00:00 app[web.1]:
2013-03-20T21:26:02+00:00 app[web.1]: ActionView::Template::Error (/app/app/views/orders/new.html.erb:31: unknown regexp options - tabl
2013-03-20T21:26:02+00:00 app[web.1]: /app/app/views/orders/new.html.erb:33: unterminated string meets end of file
2013-03-20T21:26:02+00:00 app[web.1]: /app/app/views/orders/new.html.erb:33: syntax error, unexpected $end, expecting keyword_end):
2013-03-20T21:26:02+00:00 app[web.1]: 28: <td><%= order.select :drop,options_for_select({"Nao",false,"Sim",true}) %></td>
2013-03-20T21:26:02+00:00 app[web.1]: 29: </tr>
2013-03-20T21:26:02+00:00 app[web.1]: 30: </tbody>
2013-03-20T21:26:02+00:00 app[web.1]: 31: </table>
2013-03-20T21:26:02+00:00 app[web.1]: 32: <%= order.submit "Criar nova Compra !"%>
2013-03-20T21:26:02+00:00 app[web.1]: 33: <% end %>
2013-03-20T21:26:02+00:00 app[web.1]: app/controllers/orders_controller.rb:16:in `new'
在我看来,有这段代码:
<%= form_for @order do |order| %>
<table>
<tbody>
<tr>
<td>Fornecedor</td>
<td>Produto</td>
<td>Quantidade</td>
<td>Nr Compra</td>
<td>Pagamento</td>
<td>Valor</td>
<td>Endereço</td>
<td>Dropship</td>
</tr>
<tr>
<td><%= order.select :seller,Place.all.map { |a| [a.place,a.place] }%></td>
<td><%= order.select :product_id,Product.all.map { |a| [a.name,a.id] } %></td>
<td><%= order.text_field :quantity,:size => 4 %></td>
<td><%= order.text_field :order_number,:size => 2%></td>
<td><%= order.select :payment,Place.all.map { |a| [a.place,a.place] }%></td>
<td><%= order.text_field :value,:size => 5 %></td>
<td><%= order.select :adress_id,Adress.all.map { |a| [a.name,a.id] }%></td>
<td><%= order.select :drop,options_for_select({"Nao",false,"Sim",true}) %></td>
</tr>
</tbody>
</table>
<%= order.submit "Criar nova Compra !"%>
<% end %>
如果有人可以帮助我,我感谢,当我尝试创建新订单时发生这种错误,谢谢
我尝试使用options_for_select和whitout,所有情况我都在heroku中收到此错误!
答案 0 :(得分:1)
您的视图中存在语法错误。我最好的猜测是,对于你的情况,是以下一行
<td><%= order.select :drop,options_for_select({"Nao",false,"Sim",true}) %></td>
</tr>
可以改写为:
<td><%= order.select :drop,options_for_select({"Nao" => false, "Sim" => true}) %></td>
</tr>
表达式{"Nao",false,"Sim",true}
在默认的Ruby语法中没有意义。
更改为此{"Nao" => false,"Sim" => true}
会产生哈希值。
更改为此["Nao",false,"Sim",true]
将生成一个数组。
根据文档,rails方法options_for_select将接受散列或数组(或任何可枚举类型)。