Skip to content

Instantly share code, notes, and snippets.

<ul id="nav_vert">
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php echo $this->drawItem($_category) ?>
<?php endforeach ?> </ul>
<?if ($_SERVER["REQUEST_URI"] == "/index.php"):?>
<li class="level0 active"><a href="<?=$this->getUrl('')?>index.php"><span>Home</span></a></li>
<?else:?>
<li class="level0"><a href="<?=$this->getUrl('')?>index.php"><span>Home</span></a></li>
<?endif?>
===============
<div class="header-nav-container">
<div class="header-nav">
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
Extracted source (around line #44):
41:
42:
43: <ol class="noDots">
44: <% @screenings.each do |screening| %>
45: <li>
ruby-1.9.2-p290 :008 > s = screening.cinema
=> #<Cinema id: 1, name: "Cineworld Aberdeen", url: "Queens Link Leisure Park, Links Road, Aberdeen", postcode: "AB24 5EN", telephone: "0871 200 2000", created_at: "2012-03-29 21:33:25", updated_at: "2012-03-29 21:33:27", external_id: 1>
ruby-1.9.2-p290 :009 > s.name
=> "Cineworld Aberdeen"
class Cinema < ActiveRecord::Base
has_many :screenings
has_many :films, :through => :screenings
has_one :location
end
<ol class="noDots">
<% @screening.cinema.each do |cinema| %>
<li>
<div data-role="collapsible" data-theme="b" data-content-theme="d" >
<h3><%= screening.name %></h3>
</div>
</li>
<% end %>
</ol>
ruby-1.9.2-p290 :006 > screening = Screening.find_by_id(2)
Screening Load (0.8ms) SELECT "screenings".* FROM "screenings" WHERE "screenings"."id" = 2 LIMIT 1
=> #<Screening id: 2, cinema_id: 1, film_id: 2>
ruby-1.9.2-p290 :007 > screening.cinema
Cinema Load (10.9ms) SELECT "cinemas".* FROM "cinemas" WHERE "cinemas"."id" = 1 LIMIT 1
=> #<Cinema id: 1, name: "Cineworld Aberdeen", url: "Queens Link Leisure Park, Links Road, Aberdeen", postcode: "AB24 5EN", telephone: "0871 200 2000", created_at: "2012-03-29 21:33:25", updated_at: "2012-03-29 21:33:27", external_id: 1>
def self.import_location(cinema_data)
@location = Location.find_or_create_by_name(cinema_data[:name])
@location.update_attribute(:url => cinema_data[:addressing])
cinema_data.each do |cinema_data|
import_location(cinema_data)
end
end
def self.import_location(cinema_data)
location = Location.find_or_create_by_title(cinema_data[:name])
cinema_url = cinema_data[:url] + cinema_data[:postcode]
location.update_attribute(:addressing, cinema_url)
end
def self.import_location(cinema_data)
location = Location.find_or_create_by_title(cinema_data[:name])
cinema_url = cinema_data[:url] + cinema_data[:postcode]
update_attribute(:adressing, cinema_url)
end