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
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.
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.
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.
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.