Hi all ! Loading fixtures doens''t seems to associate my 2 objects, do know what''s wrong ? In app/ class Manager < Employee has_many :employees, :foreign_key => :reports_to end class Employee < Person belongs_to :manager, :foreign_key => ''reports_to'' end class Person < ActiveRecord::Base belongs_to :address end fixtures for people Nicolas: first_name: Nicolas type: Employee reports_to: david David: first_name: David type: Manager after loading the fixtures, in the console>> e=Employee.find(:first)=> #<Employee id: 5038945, type: "Employee", title_id: nil, first_name: "Nicolas", reports_to: 0, created_at: "2008-07-20 18:33:49", updated_at: "2008-07-20 18:33:49">>> e.reports_to=> 0 Loading fixtures doens''t seems to associate my 2 objects, do know what''s wrong ? -- 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 -~----------~----~----~----~------~----~------~--~---
On 20 Jul 2008, at 18:20, nico Itkin wrote:> > fixtures for people > > Nicolas: > first_name: Nicolas > type: Employee > reports_to: david > > David: > first_name: David > type: Manager >That should be reports_to: David (it must exactly match the fixture label) Fred> after loading the fixtures, in the console > >>> e=Employee.find(:first) > => #<Employee id: 5038945, type: "Employee", title_id: nil, > first_name: > "Nicolas", reports_to: 0, created_at: "2008-07-20 18:33:49", > updated_at: > "2008-07-20 18:33:49"> > >>> e.reports_to > => 0 > > Loading fixtures doens''t seems to associate my 2 objects, do know > what''s > wrong ? > -- > 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 20 Jul 2008, at 18:20, nico Itkin wrote: > >> type: Manager >> > > That should be reports_to: David > (it must exactly match the fixture label) > > Fredproblem problem with Nicolas: first_name: Nicolas type: Employee reports_to: David Nicolas is still reporting to 0 instead of David id ... -- help -- -- 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 -~----------~----~----~----~------~----~------~--~---
On 20 Jul 2008, at 18:43, nico Itkin wrote:> > Frederick Cheung wrote: >> On 20 Jul 2008, at 18:20, nico Itkin wrote: >> >>> type: Manager >>> >> >> That should be reports_to: David >> (it must exactly match the fixture label) >> >> Fred > > problem problem with > > Nicolas: > first_name: Nicolas > type: Employee > reports_to: David >I''m being slow - you need to use the association name, not the column name (ie manager: David) Fred> Nicolas is still reporting to 0 instead of David id ... > > -- help -- > -- > 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 20 Jul 2008, at 18:43, nico Itkin wrote: > >>> Fred >> >> problem problem with >> >> Nicolas: >> first_name: Nicolas >> type: Employee >> reports_to: David >> > I''m being slow - you need to use the association name, not the column > name (ie manager: David) > > Fredthanks works great now !! -- 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 -~----------~----~----~----~------~----~------~--~---
nico Itkin wrote:> Frederick Cheung wrote: >> On 20 Jul 2008, at 18:43, nico Itkin wrote: >> >>>> Fred >>> >>> problem problem with >>> >>> Nicolas: >>> first_name: Nicolas >>> type: Employee >>> reports_to: David >>> >> I''m being slow - you need to use the association name, not the column >> name (ie manager: David) >> >> Fred > > > thanks works great now !!a last question of you''re still here : how to implement via collections has_and_belongs_to_many ? -- 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> >> Nicolas: >> first_name: Nicolas >> type: Employee >> reports_to: David >> > I''m being slow - you need to use the association name, not the column > name (ie manager: David)Does this mean the fixture system now reads and navigates the Models'' has_many etc associations? That''s new - and incredibly needed! (Our 1.2.x fixtures at work have grown so dense that adding new ones, to set new scenarios up, is a positive drain on our velocity!) -- Phlip --~--~---------~--~----~------------~-------~--~----~ 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 20 Jul 2008, at 19:46, nico Itkin wrote:> > nico Itkin wrote: >> Frederick Cheung wrote: >>> On 20 Jul 2008, at 18:43, nico Itkin wrote: >>> >>>>> Fred >>>> >>>> problem problem with >>>> >>>> Nicolas: >>>> first_name: Nicolas >>>> type: Employee >>>> reports_to: David >>>> >>> I''m being slow - you need to use the association name, not the >>> column >>> name (ie manager: David) >>> >>> Fred >> >> >> thanks works great now !! > > a last question of you''re still here : how to implement via > collections > has_and_belongs_to_many ?This is in the docs: http://api.rubyonrails.com/classes/Fixtures.html but in a nutshell: - you don''t need to specify the join table at all - just comma separate the labels of the appropriate records eg if an employee had and belongs to many projects you might have Nicholas: projects: death_star, relaunch, nemesis to say that that user is a member of those projects. Fred> > -- > 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 -~----------~----~----~----~------~----~------~--~---
On 20 Jul 2008, at 19:51, Phlip wrote:> > Frederick Cheung wrote: >> >>> Nicolas: >>> first_name: Nicolas >>> type: Employee >>> reports_to: David >>> >> I''m being slow - you need to use the association name, not the column >> name (ie manager: David) > > Does this mean the fixture system now reads and navigates the > Models'' has_many > etc associations? That''s new - and incredibly needed! >It was new in 2.0. http://api.rubyonrails.com/classes/Fixtures.html has some examples and googling for ''foxy fixtures'' should turn up some more. Fred> (Our 1.2.x fixtures at work have grown so dense that adding new > ones, to set new > scenarios up, is a positive drain on our velocity!) > > -- > Phlip > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Phlipyes -- 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 -~----------~----~----~----~------~----~------~--~---
> This is in the docs: http://api.rubyonrails.com/classes/Fixtures.html > but in a nutshell: > - you don''t need to specify the join table at all > - just comma separate the labels of the appropriate records eg if an > employee had and belongs to many projects you might have > > > Nicholas: > projects: death_star, relaunch, nemesis > > to say that that user is a member of those projects. > > Fredthanks a lot Fred. -- 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 -~----------~----~----~----~------~----~------~--~---