Hi Bryan: Bryan Crossland wrote in post #993150: >> PremiseWeatherStation.create(:premise => self, :weather_station => >> station) > I've been unable to reproduce your error in the rails server or in the > console. However, what I do see is that "self" is a reserved word. The > variable name of the object you want to pass in should not be called > "self".
Thank you for digging around. I should have shown more context -- 'self' is in fact what I intended: ========= class Premise < ActiveRecord::Base has_many :premise_weather_stations, :dependent => :destroy has_many :weather_stations, :through => :premise_weather_stations ... def find_local_weather_stations stations = WeatherStation.find_stations_near(self) premise_weather_stations = stations.map do |station| PremiseWeatherStation.create(:premise => self, :weather_station => station) end end ... end ========= which is to say, find_local_weather_stations is an instance method which associates this Premise ('self') with a list of WeatherStation ('station') objects, creating a PremiseWeatherStation object to form each association. What's really odd is that I monkey patched the raise_on_type_mismatch() method to print out the record and the @reflection. Regardless of where I run them (console, test, or server), they print out as the same. HOWEVER, record.is_a?(@reflection.klass) returns true in the console or test suite, false in the server. I'm really mystified. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.