开发者

Error happens when I read items in DataMapper

 class List
        include DataMapper::Resource

        property :id,         Serial
        property :name,      开发者_JAVA技巧 String
        property :items,      String
    end
    List.auto_migrate!

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

I get undefined method `items' for #. Any ideas?


You fetch a collection of lists instead of a single list instance, that's why you get the error. I believe you want to do:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜