Hello, I''ve been using the fixture enhancements in edge rails to manage associations between objects. It has been working great except for polymorphic associations. I saw that they weren''t supported in Rathole. I read some post that the id''s generated by the fixtures are constant so I just pulled the generated id''s and manually set the polymorphic id and the polymorphic type in the fixture as well. This worked great locally on my machine, but when I moved the application to a staging are the generated id''s were different, breaking all of the associations. Anyone have any better luck with another approach? --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 16, 2007, at 10:03 AM, Dan wrote:> I read some post that the id''s generated by the fixtures are constant > so I just pulled the generated id''s and manually set the polymorphic > id and the polymorphic type in the fixture as well.Hi Dan, You can insert the generated ID for any fixture using ERB: foo: bar_id: <%= Fixtures.identify(:the_target_fixture_label) %> As far as polymorphic assoiations go, take a look at this patch: http://dev.rubyonrails.org/ticket/10183 ~ j. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You actually don''t need the patch to support polymorphic relationships. The patch suggests this: # instead of saying foo: pet_id: 1 # a pet fixture labelled "horace" pet_type: Ferret # you can say foo: pet: horace (Ferret) But in fact you can do this: foo: pet: horace pet_type: Ferret This is good enough for me. Tiago Macedo John Barnette wrote:> On Nov 16, 2007, at 10:03 AM, Dan wrote: > >> I read some post that the id''s generated by the fixtures are constant >> so I just pulled the generated id''s and manually set the polymorphic >> id and the polymorphic type in the fixture as well. >> > > Hi Dan, > > You can insert the generated ID for any fixture using ERB: > > foo: > bar_id: <%= Fixtures.identify(:the_target_fixture_label) %> > > As far as polymorphic assoiations go, take a look at this patch: > http://dev.rubyonrails.org/ticket/10183 > > > ~ j. > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for the replies. I''ve been trying this syntax> foo: > pet: horace > pet_type: Ferretand the relationship isn''t resolving. This is in edge and I don''t need a patch? --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
It''s working for me in edge, as long as I don''t specify ids for fixtures (currently this will disable foxy fixtures). There is a patch in the Rails Trac that allows you to specify ids and still use foxy fixtures: http://dev.rubyonrails.org/ticket/10004/ As I need this patch and don''t want to use a monkey patched version of Rails, I turned this into a plugin: http://portugueserb.rubyforge.org/svn/plugins/mixed_fixtures/ Tiago Macedo Dan wrote:> Thanks for the replies. > > I''ve been trying this syntax > > >> foo: >> pet: horace >> pet_type: Ferret >> > > and the relationship isn''t resolving. This is in edge and I don''t > need a patch? > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---