gundestrup-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2009-Mar-06 09:35 UTC
Association broken when upgrading from rails 1.2.6 to 2.2.2
I have an app with the following models: course belongs_to :semester semester has_many: courses belongs_to :education education has_many :semesters In my old app (rails 1.2.6) I was able to access variables via controller @courses = Course.find(:all) view file: <% for course in @courses %> <%= course.name %> <- this line works <%= course.semester.name %> <- this is now broke <%= course.semester.education.name %> <-this is now broken. When upgrading to rails 2.2.2 all this is broken. What changed? I only changed the enviroment.rb to rails 2.2.2 and did rake rails:upgrade --~--~---------~--~----~------------~-------~--~----~ 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
2009-Mar-06 10:35 UTC
Re: Association broken when upgrading from rails 1.2.6 to 2.2.2
On Mar 6, 9:35 am, "gundest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <gundest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> In my old app (rails 1.2.6) I was able to access variables via > > controller > @courses = Course.find(:all) > > view file: > <% for course in @courses %> > <%= course.name %> <- this line works > <%= course.semester.name %> <- this is now broke > <%= course.semester.education.name %> <-this is now broken. > > When upgrading to rails 2.2.2 all this is broken.In what way is it broken ? What happens ? Fred> What changed? > > I only changed the enviroment.rb to rails 2.2.2 and did rake > rails:upgrade--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
gundestrup
2009-Mar-06 12:23 UTC
Re: Association broken when upgrading from rails 1.2.6 to 2.2.2
Error: You have a nil object when you didn''t expect it! The error occurred while evaluating nil.name the view <%= link_to course.semester.name, :controller => ''reporting'', :action => ''new'', :id => course.id %> the database: On Mar 6, 11:35 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Mar 6, 9:35 am, "gundest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <gundest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > In my old app (rails 1.2.6) I was able to access variables via > > > controller > > @courses = Course.find(:all) > > > view file: > > <% for course in @courses %> > > <%= course.name %> <- this line works > > <%= course.semester.name %> <- this is now broke > > <%= course.semester.education.name %> <-this is now broken. > > > When upgrading to rails 2.2.2 all this is broken. > > In what way is it broken ? What happens ? > > Fred > > > What changed? > > > I only changed the enviroment.rb to rails 2.2.2 and did rake > > rails:upgrade--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
gundestrup
2009-Mar-06 12:25 UTC
Re: Association broken when upgrading from rails 1.2.6 to 2.2.2
Error: You have a nil object when you didn''t expect it! The error occurred while evaluating nil.name the view <%= link_to course.semester.name, :controller => ''reporting'', :action => ''new'', :id => course.id %> the database: courses --------------- name semester_id semesters ---------------- name education_id educations ------------------ name On Mar 6, 11:35 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Mar 6, 9:35 am, "gundest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <gundest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > In my old app (rails 1.2.6) I was able to access variables via > > > controller > > @courses = Course.find(:all) > > > view file: > > <% for course in @courses %> > > <%= course.name %> <- this line works > > <%= course.semester.name %> <- this is now broke > > <%= course.semester.education.name %> <-this is now broken. > > > When upgrading to rails 2.2.2 all this is broken. > > In what way is it broken ? What happens ? > > Fred > > > What changed? > > > I only changed the enviroment.rb to rails 2.2.2 and did rake > > rails:upgrade--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
in that view, does <%= course.class %> <%= course.semester_id %> give you something like this Course 32 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
gundestrup
2009-Mar-06 12:53 UTC
Re: Association broken when upgrading from rails 1.2.6 to 2.2.2
jep, you are 100% correct. On Mar 6, 1:47 pm, MaD <mayer.domi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> in that view, does > <%= course.class %> > <%= course.semester_id %> > give you something like this > Course > 32--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Mar-06 14:28 UTC
Re: Association broken when upgrading from rails 1.2.6 to 2.2.2
And is there a semester with that id ? Fred On Mar 6, 12:53 pm, gundestrup <gundest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> jep, you are 100% correct. > > On Mar 6, 1:47 pm, MaD <mayer.domi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > in that view, does > > <%= course.class %> > > <%= course.semester_id %> > > give you something like this > > Course > > 32--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
gundestrup
2009-Mar-06 14:39 UTC
Re: Association broken when upgrading from rails 1.2.6 to 2.2.2
This is so embarrising. No, when doing rake up and down, all of my fixtures files are interpeted differently. so now I have to specify the id column, it''s not just a normal incriment column, when migrating :-( Sorry for all the fuss, I just completely missed this. On Mar 6, 3:28 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> And is there a semester with that id ? > > Fred > > On Mar 6, 12:53 pm, gundestrup <gundest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > jep, you are 100% correct. > > > On Mar 6, 1:47 pm, MaD <mayer.domi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > in that view, does > > > <%= course.class %> > > > <%= course.semester_id %> > > > give you something like this > > > Course > > > 32--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Mar-06 20:44 UTC
Re: Association broken when upgrading from rails 1.2.6 to 2.2.2
On Mar 6, 2:39 pm, gundestrup <gundest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> This is so embarrising. > No, when doing rake up and down, all of my fixtures files are > interpeted differently. > so now I have to specify the id column, it''s not just a normal > incriment column, when migrating :-( >That is a rails 2.something differnce: if the id column is not specified it is autogenerated according to some deterministic method. THis is part of something called "foxy fixtures". What it boils down to is that you used to have to have stuff like bobs_order: user_id: 4 in orders.yml and bob: id: 4 name: bob in users.yml. since this change you can have bobs_order: user: bob and bob: name: bob Because rails knows what id bob will be assigned it can wire things up and you end up with neater fixture files without a million hardcoded ids. Fred> Sorry for all the fuss, I just completely missed this. > > On Mar 6, 3:28 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > And is there a semester with that id ? > > > Fred > > > On Mar 6, 12:53 pm, gundestrup <gundest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > jep, you are 100% correct. > > > > On Mar 6, 1:47 pm, MaD <mayer.domi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > in that view, does > > > > <%= course.class %> > > > > <%= course.semester_id %> > > > > give you something like this > > > > Course > > > > 32--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
gundestrup
2009-Mar-06 21:43 UTC
Re: Association broken when upgrading from rails 1.2.6 to 2.2.2
jep, I fixed the problem, by manually editing my .yml file... I am so sorry for not realising the stupid simple issue. It would be nice if there was a way to avoid editing every line on your yaml file :-( Some kind of switch. But I can''t find one. Thanx for all of your patient help. And have a wonderfull weekend. regards svend On Mar 6, 9:44 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Mar 6, 2:39 pm, gundestrup <gundest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> This is so embarrising. > > No, when doing rake up and down, all of my fixtures files are > > interpeted differently. > > so now I have to specify the id column, it''s not just a normal > > incriment column, when migrating :-( > > That is a rails 2.something differnce: if the id column is not > specified it is autogenerated according to some deterministic method. > THis is part of something called "foxy fixtures". What it boils down > to is that you used to have to have stuff like > > bobs_order: > user_id: 4 > > in orders.yml > > and > bob: > id: 4 > name: bob > in users.yml. > > since this change you can have > > bobs_order: > user: bob > > and > bob: > name: bob > > Because rails knows what id bob will be assigned it can wire things up > and you end up with neater fixture files without a million hardcoded > ids. > > Fred > > > Sorry for all the fuss, I just completely missed this. > > > On Mar 6, 3:28 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > And is there a semester with that id ? > > > > Fred > > > > On Mar 6, 12:53 pm, gundestrup <gundest...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > jep, you are 100% correct. > > > > > On Mar 6, 1:47 pm, MaD <mayer.domi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > in that view, does > > > > > <%= course.class %> > > > > > <%= course.semester_id %> > > > > > give you something like this > > > > > Course > > > > > 32--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---