Sunday, 15 May 2011

Rails & Postgresql create a field that auto increments from 1 -



Rails & Postgresql create a field that auto increments from 1 -

i'm looking create field called id_visual in table orders starts @ 1 , auto increments there. create method in model thought there must improve more foolproof way. ideas?

from can tell, want secondary id based on primary id? identity key can table based , can not dependent on key. have in code , save new field on before_create. easiest way each order want id, count of orders less or equal 1 working based on whatever primary key is. simple 1 query calculation.

ruby-on-rails-3 postgresql auto-increment

No comments:

Post a Comment