Database: Oracle 10g
Table with fields:
(No primary key declaration)
class Myclass < ActiveRecord::Base
self.primary_key = ‘rec_no’
self.sequence_name = ‘s_rn_mytable’
As you can see as described in the model there is a sequence in the DB
that generates a unique number.
REC_NO is being used as “primary key” and should be receiving the
unique generated value.
ID is used to store values (not unique) from another table.
When a record is created the value of ID is always nil with the model
above. If I change the primary key description in the model and
specify the column ID (self.primary_key = ‘id’) I can assign values to
ID (although a varchar column the stored numbers are numeric so it
lets me do it) but then REC_NO gets the value nil.
Is there a way to make this work the ‘rails’ way? I’d rather not use
SQL, which allows me to create the records the way I need.
Thanks a lot.