Skip to content

Instantly share code, notes, and snippets.

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]}
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]}
class Cinemas < ActiveRecord::Migration
def up
add_column :postcode, :string, :telephone, :integer
def down
end
end
class Cinemas < ActiveRecord::Migration
def up
add_column :cinemas, :postcode, :string
add_column :cinemas, :telephone, :integer
def down
remove_column :cinemas, :telephone
remove_column :cinemas, :postcode
end
end
<cinemas>
<cinema name=" " phone=" " address=" " postcode=" " root=" " url="/cinemas/1" id="1">
<films>
<film title="" rating="PG" release="24/10/2011">
<shows>
<show date="Sun 30 Oct" time="10:40" videoType="digital"/><show date="Sun 30 Oct" time="13:10" videoType="digital"/>
</shows>
</film>
</films>
</cinema>
require 'nokogiri'
require 'open-uri'
class CinemaFilms
def self.get_film_links
doc = Nokogiri::XML(open('http://Whatever.com/ruby/all-performances.xml'))
doc.xpath('//film[@title]').map do |i|
{title: i[:title], rating: i[:rating], release: i[:release], length: i[:length], poster: i[:poster], director: i[:director], synopsis: i[:synopsis], cast: i[:cast] }
Morevue::Application.routes.draw do
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
ActiveRecord::RecordNotFound in FilmsController#index
Couldn't find Cinema without an ID
Rails.root: /Users/staceyrhodes/Documents/Whatever/morevue
Application Trace | Framework Trace | Full Trace
app/controllers/films_controller.rb:5:in `index'
require 'nokogiri'
require 'open-uri'
class CinemaFilms
belongs_to :cinemas
def self.get_film_links
doc = Nokogiri::XML(open('http://jagmit.co.uk/ruby/all-performances.xml'))
doc.xpath('//film[@title]').map do |i|
{title: i[:title], rating: i[:rating], release: i[:release], length: i[:length], poster: i[:poster], director: i[:director], synopsis: i[:synopsis], cast: i[:cast] }
<h1 style="text-transform:uppercase;text-align:center;border-bottom:2px solid black;padding-bottom:10px;">Cinema listings for Cineworld</h1>
<table>
<tr>
<th style="text-decoration:underline;">ID</th>
<th style="padding-right:50px;"></th>
<th style="text-decoration:underline;">Name</th>
<th style="padding-right:50px;"></th>
<th style="text-decoration:underline;">Address</th>
<th style="padding-right:50px;"></th>