我需要一些帮助来打印我的哈希值。在我的“web.rb”文件中,我有:
class Main < Sinatra::Base
j = {}
j['Cordovan Communication'] = {:title => 'UX Lead', :className => 'cordovan', :images => ['http://placehold.it/350x150','http://placehold.it/350x150','http://placehold.it/350x150']}
j['Telia'] = {:title => 'Creative Director', :className => 'telia', :images => ['http://placehold.it/350x150','http://placehold.it/350x150','http://placehold.it/350x150','http://placehold.it/350x150']}
get '/' do
@jobs = j
erb :welcome
end
end
在“welcome.rb”中,我正在打印哈希值,但它不起作用:
<% @jobs.each do |job| %>
<div class="row">
<div class="span12">
<h2><%=h job.title %></h2>
</div>
</div>
<% end %>
这是我的错误信息:
NoMethodError at / undefined method `title' for #<Array:0x10c144da0>