Below is very simple Ruby code that gets the weather. I'm trying Rails for the first time and am having a hard time adding the ruby code to my pages_controller.rb
My question is how to best add the code into my controller.
I haven't seen any tutorials that breaks this down simply. Any help/examples are appreciated.
def your_destination
puts "Where are you going?"
@trip_destination = gets.chomp
HTTParty.get("http://api.wunderground.com/api/#######key######/geolookup/conditions/q/#{@trip_destination}.json")
end
def weather_values(your_destination)
current_temp = your_destination.parsed_response['current_observation']['temp_f'].to_s
current_condition = your_destination.parsed_response['current_observation']['weather'].to_s
puts "It is " + current_temp + " and " + current_condition + "!"
end
weather_values(your_destination)
This isn't rails. This is plain ruby. Try railstutorial.org. they have an excellent eBook you can read online for free