当我在DataMapper中读取项时发生错误

时间:2010-02-28 04:43:27

标签: ruby sinatra datamapper

 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

我为#获取了未定义的方法`items'。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

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

@list = List.get(params[:id])