Reputation: 1085
I am following the Tuts+ Sinatra course and I am getting an error. Here is my code:
config.ru
require "./app"
run App
app.rb
require "sinatra/base"
IMAGES [
{ title: "Utopia", url: "http://www.techno-utopia.com/techno-utopia.jpg" },
{ title: "Alaska", url: "http://www.cruisebrothers.com/images/Destinations/Alaska.jpg" },
{ title: "The Unknown", url: "http://www.tasospagakis.com/wp-content/uploads/2012/11/fear_of_the_unknown_by_ilhaman-d4cukmg1.jpg" }
]
class App < Sinatra::Base
get "/images" do
@images = IMAGES
erb :images
end
get "/images/:index" do |index|
@image = IMAGES[index]
end
get "/" do
"Hello world!"
end
post "/" do
"Hello world via POST!"
end
put "/" do
"Hello world via PUT!"
end
delete "/" do
"Goodbye world via DELETE!"
end
get "/hello/:first_name/?:last_name?" do |first, last|
"Hello #{first} #{last}"
end
end
/views/images.erb
<h1>Images</h1>
<% @images.each do |image| %>
<h2><%= image[:title] %></h2>
<img src="<%= image[:url] %>">
<% end %>
Here is the error when I run rackup
:
As always - thanks very much for any help you may be able to provide!
Upvotes: 0
Views: 169
Reputation: 4330
You just miss a =
IMAGES = [
{ title: "Utopia", url: "http://www.techno-utopia.com/techno-utopia.jpg" },
{ title: "Alaska", url: "http://www.cruisebrothers.com/images/Destinations/Alaska.jpg" },
{ title: "The Unknown", url: "http://www.tasospagakis.com/wp-content/uploads/2012/11/fear_of_the_unknown_by_ilhaman-d4cukmg1.jpg" }
]
Variables are declared and assigned values by placing the variable name and the value either side of the assignment operator (=). Source
Upvotes: 2