Corrections:

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, the
model shows the values I entered but they are overridden anyway by the
DB.

Pepe

On May 22, 9:12 pm, pepe <p...@betterrpg.com> wrote:
> ruby: 1.8.6
> rails: 2.3.2
> Database: Oracle 10g
>
> Table with fields:
>   ID varchar2(6)
>   REC_NO number(10,0)
>   (No primary key declaration)
>
> Model:
>   class Myclass < ActiveRecord::Base
>     self.primary_key = 'rec_no'
>     self.sequence_name = 's_rn_mytable'
>   end
>
> 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.
>
> Pepe
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to