@item = items.filter(:id => params[:id])
returns a dataset. If you want a single item, you should do: @item = items.first(:id => params[:id].to_i)
Also @item.id
is probably not want you want. Given that items = DB[:items]
, you are using a plain dataset and then @item = items.first(:id => params[:id].to_i)
is going to give you a hash. You need to do @item[:id]
to get the item's id.
You may want to look at using models instead:
# model file
class Item < Sequel::Model; end
# sinatra code
@item = Item[params[:id].to_i]
# template
@item.id