【发布时间】:2016-11-04 09:26:38
【问题描述】:
我正在使用 rails 4.2 和 postgresql,并且正在处理现有的非 rails 数据库。表模式如下:
# == Schema Information
#
# Table name: customer
#
# CustomerNo :text default("P'::text || nextval('sqcustomer_no"), not null, primary key
# CustomerOperatorId :string(8)
# CustomerType :integer
# BrokerId :string(250)
# Address :text
# SalutationId :integer
问题是:
customer = Customer.create! #successfully created
customer.id #nil value
customer.CustomerNo #nil value
我正在使用 2 个扩展名 postgis, plpgsql 和 Coutomer.count 正确增加。
我试过customer.reload 它给我错误。
customer 实例变量的输出
#<Customer CustomerNo: "P'::text || nextval('sqcustomer_no", CustomerOperatorId: nil, CustomerType: nil, BrokerId: nil, Address: nil, SalutationId: nil>
知道为什么我会得到这个吗?
谢谢 尼利什
【问题讨论】:
-
这里有什么用的吗? stackoverflow.com/questions/5975081/…
-
@DavidAldridge 我做了但没有工作。
标签: ruby-on-rails postgresql ruby-on-rails-4 activerecord