0
我正在開發一個Rails應用程序,並希望將我已經從XML文件中讀取的一些信息顯示在新頁面中。如何從控制器方法向HTML頁面發送信息?
在我看來,我有:
<%= link_to 'Hoteles', :method => :hotels %>
和控制器的方法是:
def hotels
url = "http://api.hotelsbase.org/search.php?longitude="[email protected]_visit.longitude+"&latitude="[email protected]_visit.latitude
data = Nokogiri::HTML(open(url))
$name = data.xpath("//name")
$fulladdress = data.xpath("//fulladdress")
$phone = data.xpath("//phone")
$city = data.xpath("//city")
$description = data.xpath("//description")
$featured = data.xpath("//featured")
$stars = data.xpath("//stars")
$rating = data.xpath("//rating")
$long = data.xpath("//long")
$lat = data.xpath("//lat")
$dist = data.xpath("//dist")
$price = data.xpath("//price")
$tripadvisorurl = data.xpath("//tripadvisorurl")
$url = data.xpath("//url")
$hotelsbaseUrl = data.xpath("//hotelsbaseUrl")
end
現在我要顯示在HTML頁面信息。