[Rails] Re: Re: AssociationTypeMismatch ( expected, got )
Okay, I have found a fix, or at least a workaround. If a Rails core
team member is reading this, I'd appreciate knowing if this warrants a
lighthouse ticket.
If I add a .reload (to the AR that is already in the db):
def load_station(candidate)
if (incumbent =
WeatherStation.find_by_callsign(candidate.callsign))
incumbent.resolve_location
incumbent.save!
incumbent.reload # RELOAD ADDED HERE
else
candidate.resolve_location
candidate.save!
candidate
end
end
... it no longer raises an AssociationTypeMismatch in this code (called
some lines later):
PremiseWeatherStation.create(:premise => self, :weather_station =>
station)
Mind you, this ONLY happens when run as a server and not in the console.
(See the OP for the schema and models). I'm going back to work on other
stuff, but if a Rails developer wants more information on this, I'd be
happy to provide it.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home