[Rails] Re: push_with_attributes quandary

Eric Anderson eric at afaik.us
Sat Jan 22 04:21:02 GMT 2005


Todd Gehman wrote:
> collection.push_with_attributes(object, join_attributes)

This is exactly the method you are looking for. There are a couple of 
bugs/problems related to this functionality although just today I 
submitted patches (#522 and #524) to take care of these so hopefully 
that should be taken care of in the next Rails release.

> ...but when I run that like so:
> 
> person.teams.push_with_attributes(team, "joined_date" => Time.now.to_i), 
> I get this error:
> 
> Track expected, got Array
[...snip...]
> didn't work either.  I must just be missing something unless this is a 
> bug.  Any ideas?

Could you paste your has_and_belongs_to_many statement in a reply so we 
can see the relationship. When you add an object to an association it 
checks to make sure the type matches. For some reason it is saying that 
the variable "team" is an Array and it was expecting a "Track" object. 
Also are you sure this error message isn't for another statement. Are 
you adding a "Track" object to something and accidentally passing an 
array instead?

I use it so I know the functionality works in Rails. Just need more info 
to track down your problem.

Eric
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature
Url : http://one.textdrive.com/pipermail/rails/attachments/20050121/58569284/signature.bin


More information about the Rails mailing list