0
 class List
        include DataMapper::Resource

        property :id,         Serial
        property :name,       String
        property :items,      String
    end
    List.auto_migrate!

    get '/:id' do
        @list = List.all(:id => params[:id])
        @items = @list.items
        erb :show
    end

我得到未定义的方法“项目”#。有任何想法吗?

4

1 回答 1

0

您获取列表集合而不是单个列表实例,这就是您收到错误的原因。我相信你想做:

@list = List.get(params[:id])
于 2010-02-28T08:19:07.323 回答