Forum: Ruby on Rails compose_primary_keys

Posted by Augustus Costa (Guest)
on 2009-07-02 14:45
(Received via mailing list)
I´m looking for a way to work with compose primary keys.
I alredy know that plugin http://compositekeys.rubyforge.org/
but it doesn´t have examples.

Please help =]

--
Horus Augustus C. C. Lima

Sagarana Tech
Mobile +55(85)8842.4402
Desk +55(85)3304.6530
augustus@sagaranatech.com
http://www.sagaranatech.com
Posted by Robert Walker (robert4723)
on 2009-07-03 01:43
Augustus Costa wrote:
> I´m looking for a way to work with compose primary keys.
> I alredy know that plugin http://compositekeys.rubyforge.org/
> but it doesn´t have examples.
What do you mean it doesn't have examples? What is this:

class Membership < ActiveRecord::Base
  # set_primary_keys *keys - turns on composite key functionality
  set_primary_keys :user_id, :group_id
  belongs_to :user
  belongs_to :group
  has_many :statuses, :class_name => 'MembershipStatus', :foreign_key => 
[:user_id, :group_id]
end
Posted by Gee-off (Guest)
on 2009-07-04 01:38
(Received via mailing list)
there's a Google group "Composite Keys for ActiveRecord" that you
might look at for tips
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.