Skip to content

Instantly share code, notes, and snippets.

@jagmitg
Created October 26, 2011 22:40
Show Gist options
  • Save jagmitg/1318238 to your computer and use it in GitHub Desktop.
Save jagmitg/1318238 to your computer and use it in GitHub Desktop.
require 'nokogiri'
require 'open-uri'
class CinemaSite
def self.get_cinema_links
doc = Nokogiri::XML(open('http://jagmit.co.uk/ruby/cinemas.xml'))
doc.xpath('//cinema[@name]').map do |i|
{name: i[:name], url: i[:url]}
if request.post?
@user = User.new(params[:user])
if @user.save
redirect_to :action => :index
end
end
end
end
end
class CinemasController < ApplicationController
def index
@links = CinemaSite.get_cinema_links
end
end
<ol>
<% @links.each do |l| %>
<li><%= link_to l[:name], l[:url] %></li>
<% end %>
<%= @links %>
</ol>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment