#1088 ✓duplicate
Robert Sköld

"can't convert String into Array" error in a very simple model

Reported by Robert Sköld | October 8th, 2009 @ 09:45 PM

I have this very simple model example:

require "rubygems"
require "dm-core"

class Store
  include DataMapper::Resource
  property :id,             Serial
  property :key,            String, :length => 255
  property :val,            String, :length => 65535
  def self.write( k , v )
    s = first_or_create( :key => k )
    s.update( :val => v )
  def self.read( k )
    s = first( :key => k )
    s.val if s
  def self.delete( k )
    s = first( :key => k )
    s.destroy! if s

DataMapper.setup(:default, "sqlite3::memory:")

session = {
  :expires => 1231233252,
  :session_key => "1234873r6yiejkh3l4k",
  :uid => 1231234532

Store.write( "sess" , session.to_s )
p Store.read( "sess" )

And it gives me these errors:

can't convert String into Array
/Users/slaskis/.gem/ruby/1.8/gems/dm-core-0.10.1/lib/dm-core/model/property.rb:181:in `zip'
/Users/slaskis/.gem/ruby/1.8/gems/dm-core-0.10.1/lib/dm-core/model/property.rb:181:in `key_conditions'
/Users/slaskis/.gem/ruby/1.8/gems/dm-core-0.10.1/lib/dm-core/resource.rb:737:in `query'
/Users/slaskis/.gem/ruby/1.8/gems/dm-core-0.10.1/lib/dm-core/resource.rb:609:in `collection'
/Users/slaskis/.gem/ruby/1.8/gems/dm-core-0.10.1/lib/dm-core/resource.rb:724:in `eager_load'
/Users/slaskis/.gem/ruby/1.8/gems/dm-core-0.10.1/lib/dm-core/resource.rb:710:in `lazy_load'
/Users/slaskis/.gem/ruby/1.8/gems/dm-core-0.10.1/lib/dm-core/property.rb:596:in `send'
/Users/slaskis/.gem/ruby/1.8/gems/dm-core-0.10.1/lib/dm-core/property.rb:596:in `lazy_load'
/Users/slaskis/.gem/ruby/1.8/gems/dm-core-0.10.1/lib/dm-core/property.rb:487:in `get'
/Users/slaskis/.gem/ruby/1.8/gems/dm-core-0.10.1/lib/dm-core/model/property.rb:200:in `val'

I don't see why?

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »