> No, I am saying you would *not* have to have two pairs. Rather, when
> you construct a Pairing, pick an unambiguous way of sorting the two
> Alphabet objects so that ab and ba will map to the same thing. For
> example (untested):
>
> class Pairing < AR::B
> before_create do
> [...@alphabet, @alphabetpartner] = [...@alphabet,
> @alphabetpartner].sort_by {|x| [x.name, x.id]}
> end
> end
Marnen many thanks again for your help.
So if i sort them by their name then id, and I have A and B with ids 1
and 2 respectively then in my pairing controller id do
@pairing = Pairing.new(params[:pairing])
@pairing.save (Which would use the callback before_create above)
So A has an Ingredient_Partner B
i.e. A.alphabet_partners ===> B
But would it work the other way i.e.
B.alphabet_partners ==> A ?????
i thought it wouldnt without creating a 2nd pairing with the letters
switched.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---