我有一个变量 page.stock,它在负载上设置为字符串“3,4,5,6”。
我想遍历这个变量。我试过:
{% for mysize in app.request.get(page.stock) %}
<input type="radio" id="{{mysize}}" name="size" value="{{mysize}}" >
<label for="{{mysize}}">{{mysize}}</label>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
我也试过:
{% for mysize in page.stock %}
<input type="radio" id="{{mysize}}" name="size" value="{{mysize}}" >
<label for="{{mysize}}">{{mysize}}</label>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
两者都没有运气。如何遍历,分隔的字符串?
以下查询是不断超时的,是否有更少的开销方式来实现相同的功能?
UPDATE Invoices SET ispaid = 0
WHERE Invoice_number IN (SELECT invoice_number
FROM payment_allocation
WHERE transactionID=305)
Run Code Online (Sandbox Code Playgroud)
我正在做的是从事务中取消分配发票,最多可以返回30多条记录,但每次我尝试运行它时都会停止数据库死机
我不知道为什么会抛出错误
if((("#panel").is(':visible') && elm.length==0)||((("#panel").is(':hidden') && elm.length>0))){
showSubMenu()
}
Run Code Online (Sandbox Code Playgroud)
("#panel").是不是一个函数???
有人可以向我解释为什么会导致错误的逻辑吗?所以我不重复?
我已经成功运行了一段时间的代码,但它刚刚开始抛出错误 - 我们已经改变了数据进入数据库的方式,但相信它更有可能是一个编程问题,或者我已经改变了它错误,但看不到哪里。
该问题似乎是由范围引起的,我们正在运行 Rails 4.2.2
完整的错误是
undefined method `call' for
ActiveRecord::QueryMethods::WhereChain:0x007feb8f5c49f0> Did you mean? caller
app/controllers/orders_controller.rb:158:in `weekly_sales_report'
Run Code Online (Sandbox Code Playgroud)
在我的 orders_controller 第 158 行
@sales_this_week_bysales = Order.select("COUNT(order_id) AS nosales, AVG(net_amount) AS avgsale,SUM(sale_cost) AS sale_cost, SUM(net_amount) AS weeklysalestotal, owner_id AS salesman").sales.where.(date_of_sale: (@startdate .. @enddate)).with_salesman.group(:owner_id)
Run Code Online (Sandbox Code Playgroud)
在我的 orders.rb 模型中,我使用了以下范围
scope :with_salesman, -> { joins(:pipe_records).where(pipe_records: {pipe_part_id: 1}).where.not(pipe_records: {owner_id: nil}) }
scope :sales, -> {where ("orders.order_ref <>'' and date_of_sale IS NOT NULL ")}
Run Code Online (Sandbox Code Playgroud)
我将范围重新写入下面,但仍然出现相同的错误
scope :with_salesman, -> { joins(" INNER JOIN pipe_records ON pipe_records.order_id = orders.id …Run Code Online (Sandbox Code Playgroud)