class Subreddit < Ohm::Model
attribute :name
index :name
def self.seed(names)
names.each do |name|
create(name: name) if find(name: name).empty?
end
end
def create_entry(attrs)
attrs[:subreddit_id] = id
entry = Entry.create(**attrs)
entry
end
end
class Entry < Ohm::Model
attribute :rid
attribute :title
attribute :url
reference :subreddit, :Subreddit
attribute :permalink
index :rid
index :url
index :subreddit
unique :rid
end
I get this error when I try to use the new_entry on Subreddit on when trying to create an Entry by hand
[1] pry(main)> Subreddit[1]
=> #<Subreddit:0x007fdd0b4f1858 @_memo={}, @attributes={:name=>"pics"}, @id=1>
[2] pry(main)> Entry.create(rid: 1, subreddit_id: 1)
NoMethodError: undefined method `to_msgpack' for #<Subreddit:0x007fdd0b539090>
from /Users/eka/dev/web/sites/rdp-sinatra/vendor/bundle/gems/ohm-2.0.1/lib/ohm.rb:1393:in `to_msgpack'
Any clue on what I'm doing wrong?