undefined method content_type

Anand Hegde anandghegde at gmail.com
Mon Jun 25 01:52:01 EDT 2012


require 'riak'




class RiakClient < Riak::Client
#attr_accessor :bucket

def initialize(hosts="")
return Riak::Client.new(:nodes => [{:http_port => 8091},{:http_port
=>8092},{:http_port=>8093},{:http_port =>8094}])
end

def get_me(bucket, key)
obj = self.bucket(bucket).get(key)
puts obj.data
end

def put_me(bucket, key, data, content_type)
obj=self.bucket(bucket).get_or_new(key)
puts obj.class
obj.content_type=content_type
obj.raw_data=data
obj.store
end
end



if __FILE__ == $0
my_client=RiakClient.new
my_client.put_me("doc", "index.html", "some data goes here", "text/html")
hash=my_client.get_me("doc", "index.html")
end


But I am getting the following errors -

NilClass
riak_client.rb:32:in `put_me': undefined method `content_type=' for
nil:NilClass (NoMethodError)
from riak_client.rb:42:in `<main>'

Do I have to import the RiakObject and RiakClient classes and all? and how
do i do this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20120625/15cb4cbb/attachment.html>


More information about the riak-users mailing list