Hello all.
I have a question about using active record and postgresql sequences.
----
My environment is:
Ruby: ruby-1.9.2-p290 [ x86_64 ]
Rails: 3.1.1.
PostgreSQL: 9.0.5.
pg: 0.11.0.
----
I  have a very simple table:
-
CREATE TABLE accounts
(
  id bigint NOT NULL,
  username character(255)
)
-
and I have a simple script for connect to DB:
--
require "rubygems"
require "active_record"

ActiveRecord::Base.establish_connection(
    :adapter => "postgresql",
    :host =>"localhost",
    :username => "test",
    :password => "",
    :database => "project_development"
)

class Account < ActiveRecord::Base
  set_sequence_name "account_seq"
  set_primary_key :id
end

account = Account.new
account.username = "User1"
account.save

-----
Task: I want  use postgresql sequence for generation of  primary  key.
          I use 'set_sequence_name', but  this don't work.

Question: How to make active use of the active record of the sequence
to generate a primary key?

-- 
Posted via http://www.ruby-forum.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