# Adding messages to a queue server from a model method

**URL:** <https://www.ruby-forum.com/t/adding-messages-to-a-queue-server-from-a-model-method/137735>\
**Category:** Rails\
**Created:** [May 15, 2008, 8:59pm UTC](https://www.ruby-forum.com/t/adding-messages-to-a-queue-server-from-a-model-method/137735 "2008-05-15T20:59:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Linicks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/a88e4f/32.png) [@Linicks](https://www.ruby-forum.com/u/Linicks)\
**Post date:** [May 15, 2008, 8:59pm UTC](https://www.ruby-forum.com/t/adding-messages-to-a-queue-server-from-a-model-method/137735/1 "2008-05-15T20:59:50Z")

</div>

All,  
I’m trying to add/‘set’ values in the sparrow queue server (http://  
[Google Code Archive - Long-term storage for Google Code Project Hosting.](http://code.google.com/p/sparrow/)) which is very similar to Starling. I can  
add values to the queue easily from an irb session or independent  
script, but not from a model method. What do I need to do to make  
this work?

####################################  
What I used in the script and irb session:

require ‘rubygems’  
require ‘memcache’  
m = MemCache.new(‘127.0.0.1:11212’)  
m[‘queue\_name’] = ‘1’ # Publish to queue

####################################

Example Model Test:

class Exmaple \< ActiveRecord::Base

def experiment

require ‘memcache’

m = MemCache.new(‘127.0.0.1:11212’)

m[‘queue\_name’] = ‘1’

end

end

Thanks!  
–Nick
