I have a rails project. I scaffolded Site and Server, their models are below. When a new site is created I want to associate it with the right server by fetching the IP that the url points to. I will run a cronjob or EventMachine to check if this data is still up to date. This way this data will stay up to date and users don’t have to maintain it.
Question is: how do I do that; how do I fetch a sites IP if I only have the url in Rails?
I’m running Rails 3 on Ruby 1.9.2.
Table name: sites
url :string(255)
name :string(255)
server_id :integer #this is a foreign key to a server
Table name: servers
ip :string(255)
name :string(255)
Take a look at
Resolv, which is part of the ruby stdlib.