私はrails 4.2 &のpostgresqlを使用しています。私は既存の非レールDBを作成しています。テーブルスキーマは、以下の通りである:作成したモデルインスタンスのPostgresのプライマリキーのデフォルト値は025です
# == 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
問題がある:私はpostgis, plpgsql
とCoutomer.count
が適切に増加2拡張子を使用してい
customer = Customer.create! #successfully created
customer.id #nil value
customer.CustomerNo #nil value
。
私はcustomer.reload
を試してみました。変数
#<Customer CustomerNo: "P'::text || nextval('sqcustomer_no", CustomerOperatorId: nil, CustomerType: nil, BrokerId: nil, Address: nil, SalutationId: nil>
customer
インスタンスの
出力
私はこれを取得していますなぜ任意のアイデア?お使いのモデルで
おかげ Neelesh
ここには何もありませんか? http://stackoverflow.com/questions/5975081/camelcase-instead-of-snake-case-in-rails-db –
@DavidAldridge私はしましたが、動作しませんでした。 – Neelesh