以下代码在开发环境 sqlite3 数据库运行正常,在 Production 环境 Postgres9.3 数据库却出现错误,是什么原因呢?请指教,谢谢!
class HomeController < ApplicationController
def index
@new_3_projects = Project.find(:all, limit:3)
@staff_pick_project = Project.first
end
end
App 18126 stdout: Processing by HomeController#index as HTML
App 18126 stdout: PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer: "all"
App 18126 stdout: LINE 1: ...cts".* FROM "projects" WHERE "projects"."id" IN ('all', '--...
App 18126 stdout: ^
App 18126 stdout: : SELECT "projects".* FROM "projects" WHERE "projects"."id" IN ('all', '---
App 18126 stdout: :limit: 3
App 18126 stdout: ') ORDER BY created_at DESC
App 18126 stdout: Completed 500 Internal Server Error in 1ms
App 18126 stdout:
App 18126 stdout: ActiveRecord::StatementInvalid (PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer: "all"
App 18126 stdout: LINE 1: ...cts".* FROM "projects" WHERE "projects"."id" IN ('all', '--...
App 18126 stdout: ^
App 18126 stdout: : SELECT "projects".* FROM "projects" WHERE "projects"."id" IN ('all', '---
App 18126 stdout: :limit: 3
App 18126 stdout: ') ORDER BY created_at DESC):
App 18126 stdout: app/controllers/home_controller.rb:3:in `index'
解决方案: rails 4 不推荐 find 了,推荐 where