Well, since no one commented, I went ahead and opened a ticket for this
(http://dev.rubyonrails.com/ticket/843) since I understand it makes no
sense to add the same object twice to an association. Unless there are
different join attributes, and still am not sure that this is the case
as well (preferring an update in this case rather than an additional insert)
I''m waiting on this to be resolved -or clarified- and then
I''ll send the
corresponding patch for #596
cheers
Victor
Victor Jalencas wrote:> In trying to add timestamp support to habtm, I''ve stumped on a
question
> which I hope you all help me solve.
> And that is, when adding a record twice to the list of associations with
> push with attributes, should the following test succeed or not?
>
> def test_pushing_twice
> dev = Devel.new("name"=>"victor")
> p = Project.new("name"=>"whatever")
> dev.projects.push_with_attributes(p, :joined_on => Date.today)
> dev.projects.push_with_attributes(p, :joined_on => Date.today)
> assert_equal(1,dev.projects.size)
> end
>
> That is, should the record be added twice, or else updated with new
> info? And for that matter, should the normal push (or <<) method add
> twice if repeated as well?
>
> I think both views are correct, it''s all a matter of semantics, is
it not?
> Let me know your thoughts
>
> Victor
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails