Created
October 26, 2011 22:40
-
-
Save jagmitg/1318238 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CinemasController < ApplicationController | |
def index | |
@links = CinemaSite.get_cinema_links | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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