On Mon, Nov 3, 2008 at 5:02 PM, gdonald <[EMAIL PROTECTED]> 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

  belongs_to :ugroup
  belongs_to :user

  def get_id
    self.user_ugroup_id = connection.next_sequence_value(
self.class.sequence_name )
  end

end



-- 
Greg Donald
http://destiney.com/

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to