模型和API类的命名重叠?

时间:2016-10-08 19:03:18

标签: ruby-on-rails ruby model-view-controller

我在我的Rails应用程序中有以下代码可以正常工作:

last_id ||= 0
status = {status: 'any', fields: 'id,order_number,email,created_at,billing_address,total_price', limit: 250, since_id: last_id}
count = ShopifyAPI::Order.count(status)

当我像这样更改第一行时出现错误

last_id = Order.find_by_sql("select max(id) from orders where id=#{ShopifyAPI::Shop.current.id}")
last_id ||= 0
status = {status: 'any', fields: 'id,order_number,email,created_at,billing_address,total_price', limit: 250, since_id: last_id}
count = ShopifyAPI::Order.count(status)

错误:

ActiveResource::BadRequest in TestController#index
Failed. Response code = 400. Response message = Bad Request.
Error is on line: count = ShopifyAPI::Order.count(status)

这是一个问题,因为Shopify API类(?)和模型的名称相同?如果是这样,它在第一个代码中起作用似乎很奇怪。

0 个答案:

没有答案