On Mar 22, 2012, at 9:33 PM, Lori M Olson wrote:
> self.primary_keys= ? When did that become the thing to use? I've been using this gem since it first appeared, and it was always:
>
> set_primary_keys [:account_id,:user_id]
ActiveRecord 3.2 deprecated[1]
set_primary_key :account_id
in favor of
self.primary_key = :account_id
CPK 5.0 permits[2] self.primary_keys= to follow this pattern.
>
> On Wednesday, March 21, 2012 6:12:05 PM UTC-6, Troy Kruthoff wrote:
> class AccountUser < ActiveRecord::Base
> self.primary_keys :account_id,:user_id
> end
So, Tony, you need to write:
self.primary_keys = [:account_id, :user_id]
(Note the '='.)
Ref: https://github.com/drnic/composite_primary_keys/blob/master/lib/composite_primary_keys/base.rb#L24
Rhett
[1]: http://guides.rubyonrails.org/3_2_release_notes.html#activerecord_deprecations
[2]: https://github.com/drnic/composite_primary_keys/blob/master/History.rdoc
>
> console:
>
>
> >> AccountUser.all
> ArgumentError: wrong number of arguments (2 for 0)
> /Users/troy/.rvm/gems/ruby-1.9.3-p0/gems/
> composite_primary_keys-5.0.2/lib/composite_primary_keys/base.rb:10:in
> `primary_keys'
> /Users/troy/Projects/node6/wtf/api/models/accounts_users/
> account_user.rb:3:in `<class:AccountUser>'
> /Users/troy/Projects/node6/wtf/api/models/accounts_users/
> account_user.rb:2:in `<top (required)>'
> (ripl):2:in `<main>'
> >> AccountUser.all
> AccountUser Load (1.0ms) SELECT "account_users".* FROM
> "account_users"
> => [#<AccountUser account_id: 1, user_id: "KrazyKrut", token:
> "2190bef01b456a9b12d5b423c30ec706", roles: nil>, #<AccountUser
> account_id: 1, user_id: "DieselGeek", token:
> "22f63b58967197db64cf1fe4be5fd878", roles: nil>]
>
>
> Any ideas? The first call to primary_keys always fails, but after
> than everything is just dandy!
>
> Thanks,
>
> Troy
>
> --
> You received this message because you are subscribed to the Google Groups "Composite Keys for ActiveRecord" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/compositekeys/-/08wp-mB9iEcJ.
> To post to this group, send email to compos...@googlegroups.com.
> To unsubscribe from this group, send email to compositekey...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/compositekeys?hl=en.
> To unsubscribe from this group, send email to compositekeys+unsubscribe@googlegroups.com.