Re: :table_name_with_underscore and join models

Greg Donald
Tue, 04 Nov 2008 16:56:21 -0000

On Tue, Nov 4, 2008 at 10:54 AM, Greg Donald
<gdonald-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> On Mon, Nov 3, 2008 at 5:02 PM, gdonald
<gdonald-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>>>> UserUgroup.create!( :user => @gdonald, :ugroup => @admin
)
>>
>> ActiveRecord tries to insert a NULL for the user_ugroups_id field and
>> then I get this:
>>
>> ActiveRecord::StatementInvalid: OCIError: ORA-01400: cannot insert
>> NULL into
("MYPROJDB"."USER_UGROUPS"."USER_UGROUPS_ID"):
INSERT INTO
>> user_ugroups (user_ugroups_id, user_id, ugroup_id) VALUES(NULL, 1, 1)
>>
>> The migration creates my USER_UGROUPS_SEQ without issue, but then it
>> doesn''t get used.
>
> For the next poor Oracle user who comes along, here''s a
workaround:
>
> class UserUgroup < ActiveRecord::Base
>
>  before_save :get_id

Oops..  that should be before_create