Re: ActiveRecord HasAndBelongsToManyAssociationWithPrimaryKeyError

Colin Law
2013-04-29T11:11:27Z

On 29 April 2013 10:35, siva kumar
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:
> Im trying to upgrade an app from rails 2.3 to rails 3.0
>
> I get the following error in rails 3.0.6 environment
>
> Error message:
>     Primary key is not allowed in a has_and_belongs_to_many join table
> (appointment_label).
> (ActiveRecord::HasAndBelongsToManyAssociationWithPrimaryKeyError)
>
> Exception class:
>     ActiveRecord::HasAndBelongsToManyAssociationWithPrimaryKeyError
>
> seems primary key should be removed from "appointment_label" so I
> removed the primary key column and it did worked PERFECT!!
>
> But what I don''t get is the app worked fine in rails 2.3
environment
> even with primary key in the table "appointment_label" but not in
rails
> 3.0.6 environment ????

Presumably it did not matter that the table had a primary key in the
earlier version (even though it was not necessary).  In Rails 3 they
have made it an error.

Colin

--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.