Bryan Crossland wrote in post #993205:
> What is the code for the method find_stations_near?

First, here's the code for find_local_weather_stations().  The create
method raises the error:

  def find_local_weather_stations(limit = 10)
    premise_weather_stations.delete_all
    stations = WeatherStation.find_stations_near(self)
    premise_weather_stations = stations[0, limit].map do |station|
      PremiseWeatherStation.create(:premise => self, :weather_station =>
station)
    end
  end

The find_stations_near(self) method calls an external web site to get
the callsigns, creates an in-memory "candidate" with that callsign, and
then saves the candidate if not already in the database, or updates the
existing one if it is.  Both paths use the save!() method, so we can be
assured that the weather_station really is in the database.
find_stations_near() ultimately returns:

    def load_stations(stations)
      stations.map {|station| load_station(station) }
    end

    def load_station(candidate)
      if (incumbent =
WeatherStation.find_by_callsign(candidate.callsign))
        incumbent.resolve_location
        incumbent.save!
        incumbent
      else
        candidate.resolve_location
        candidate.save!
        candidate
      end
    end

I don't see anything odd in that code.

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

Reply via email to