我正在跟踪Tuts+西纳屈课程,并得到了一个错误。这是我的代码:
config.ru
require "./app"
run Appapp.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/视图/图像。
<h1>Images</h1>
<% @images.each do |image| %>
<h2><%= image[:title] %></h2>
<img src="<%= image[:url] %>">
<% end %>下面是我运行rackup时的错误

一如既往-非常感谢您能提供的任何帮助!
发布于 2014-04-13 10:03:20
你只是错过了一个=
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" }
] 变量通过放置变量名和赋值操作符(=)的任何一方来声明和赋值。来源
https://stackoverflow.com/questions/23041262
复制相似问题