Frederick Cheung wrote: > is there a belongs_to :start_time ? > If so then it's the accessor for that association that's being called, > not the attribute reader (and it's nil because the object at hand has > no start_time_id > > Fred
Give this man a cigar! That's exactly what's going on. class WeatherObservation < ActiveRecord::Base belongs_to :start_time, :class_name => 'TimeDimension', :foreign_key => 'start_time_id' belongs_to :end_time, :class_name => 'TimeDimension', :foreign_key => 'end_time_id' belongs_to :weather_station ... end The ActiveRecord::Associations::ClassMethods doc has a nice section on "auto generated methods" -- I didn't notice that it's the argument to :belongs_to that defines the method name and not :foreign_key, i.e. it generates: WeatherObservation#start_time rather than: WeatherObservation#start_time_id Good catch -- thanks. -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

