Heya, I''m using globalize2 and have following problem with my fixtures: categories.yml: one: parent_id: two color: #ff00aa two: color: #00ff11 three: parent_id: two color: #ab00ab category_translations.yml one-en: id: one locale: en name: Cars one-es: id: one locale: es name: Coches two-en: id: two locale: en name: Start two-es: id: two locale: es name: Inicio three-en: id: three locale: en name: Bicycles three-es: id: three locale: es name: Bicicletas My problem now is that in my translations table all id''s are NULL which is kinda obvious cause the fixture has no idea where one, two and three is. Does anyone know how to load a fixture inside a fixture in order to use them? -- 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-/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 -~----------~----~----~----~------~----~------~--~---
How about using erb? <%= find_by_id(<some-id>) %> On Mar 28, 1:41 pm, Heinz Strunk <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Heya, > > I''m using globalize2 and have following problem with my fixtures: > > categories.yml: > one: > parent_id: two > color: #ff00aa > > two: > color: #00ff11 > > three: > parent_id: two > color: #ab00ab > > category_translations.yml > one-en: > id: one > locale: en > name: Cars > > one-es: > id: one > locale: es > name: Coches > > two-en: > id: two > locale: en > name: Start > > two-es: > id: two > locale: es > name: Inicio > > three-en: > id: three > locale: en > name: Bicycles > > three-es: > id: three > locale: es > name: Bicicletas > > My problem now is that in my translations table all id''s are NULL which > is kinda obvious cause the fixture has no idea where one, two and three > is. Does anyone know how to load a fixture inside a fixture in order to > use them? > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Harold wrote:> How about using erb? > > <%= find_by_id(<some-id>) %> > > On Mar 28, 1:41�pm, Heinz Strunk <rails-mailing-l...-ARtvInVfO7m5VldFQK4jKA@public.gmane.orgt>First of all: I don''t know the id because it''s set randomly :) I could set it in the other yml and then just use them but I''d actually prefer using rails generated ids. I could use find_by_whatever but I''d like to use fixtures only if possible. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Heinz Strunk wrote:> categories.yml: > one: > parent_id: two > color: #ff00aaone''s raw ID is a hash of its identifier. Get it with <%= Fixture.identify(:one) %>> two: > color: #00ff11 > > three: > parent_id: twoThat should be parent: two Only use Fixture.identify() if you can''t link up the real identifier, through either belongs_to or has_and_belongs_to_many. The point is to allow the Fixture system to install one database table by reading the minimum possible of its associated model, and by reading no other model or fixture file. If globalize2 can''t track these associations, you must use either Fixture.identify(), or you must fall back to old-fashioned Rails 1 fixtures, where everything has an id: with a hand-coded number in it... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
<%= Fixture.identify(:one) %> sounds great to me, thank you! :) parent:, of course... typo. -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Um well... I use two different yml-files so it doesn''t find the identifiers from the other files. How do I tell him to look in the other one? -- 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-/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 -~----------~----~----~----~------~----~------~--~---
I don''t get that...it doesn''t really look at any other yml, it just calculates a hash:>> Fixtures.identify(:one)=> 953125641>> Fixtures.identify(:two)=> 996332877 How are you calling this? -H On Mar 28, 2:34 pm, Heinz Strunk <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Um well... I use two different yml-files so it doesn''t find the > identifiers from the other files. How do I tell him to look in the other > one? > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 28, 6:34 pm, Heinz Strunk <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Um well... I use two different yml-files so it doesn''t find the > identifiers from the other files. How do I tell him to look in the other > one?It doesn''t need to - the value of Fixture.identify(foo) depends only on foo itself (that''s the whole point: being able to predict what id a fixture with a given label will have). Fred> -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> >> Fixtures.identify(:one) > => 953125641 > >> Fixtures.identify(:two) > => 996332877 >Frederick Cheung wrote:> On Mar 28, 6:34�pm, Heinz Strunk <rails-mailing-l...-ARtvInVfO7m5VldFQK4jKA@public.gmane.orgt> > wrote: >> Um well... I use two different yml-files so it doesn''t find the >> identifiers from the other files. How do I tell him to look in the other >> one? > > It doesn''t need to - the value of Fixture.identify(foo) depends only > on foo itself (that''s the whole point: being able to predict what id a > fixture with a given label will have). > > FredOh, I thought I could call that fixture from the other file directly so I guess the only thing I can do is category_translations.yml one-en: id: <%= Category.find_by_id(Fixtures.identify(:one)) %> locale: en name: Cars one-es: id: <%= Category.find_by_id(Fixtures.identify(:one)) %> locale: es name: Coches ...? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
The finder call to the DB is redundant. How about you save yourself the trip to the db and just do one-en: id: <%= Fixtures.identify(:one) -%> locale: en name: cars On Sun, Mar 29, 2009 at 9:15 AM, Heinz Strunk < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Oh, I thought I could call that fixture from the other file directly so > I guess the only thing I can do is > > category_translations.yml > one-en: > id: <%= Category.find_by_id(Fixtures.identify(:one)) %> > locale: en > name: Cars > > one-es: > id: <%= Category.find_by_id(Fixtures.identify(:one)) %> > locale: es > name: Coches > ...? > -- > 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-/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 -~----------~----~----~----~------~----~------~--~---
Alright, it''s working now. Thanks guys! -- 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-/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 -~----------~----~----~----~------~----~------~--~---