Translating to XML

1 view
Skip to first unread message

Dr. Manitoba

unread,
Apr 5, 2010, 7:53:41 PM4/5/10
to Grackle Development
I'm using Grackle to power a Rails-based backend for a Flex app.

This being said, my goal in the Rails app is to perform the calls to
Twitter, and then feed those responses, via an XML document, to the
Flex app, in order to be parsed.

One example of such a function looks like this:

def search
if client
@tweets = client[:search].search? :q => params[:search]

respond_to do |format|
format.html
format.xml { render :layout => false,
:xml => @tweets.to_xml }
end
end
end

I then have an xml.builder file for that function, which looks like
this:

xml.instruct!
xml.results do
@tweets.results.each do |tweet|
xml.tweet do
xml.from_user tweet.from_user
xml.text tweet.text
end
end
end

This all works out swimingly. Even better, I have an alternate HTML
template that also renders this data JUST fine.

However, I have another method, like-a so:

def user_search
if client
@tweets = client.statuses.user_timeline? :id => params[:user]

respond_to do |format|
format.html
format.xml { render :layout => false,
:xml => @tweets }
end
end
end

Looks roughly the same, yes? Passing this on to the standard HTML
template renders the data as expected. This means to me that the
request is successful, my query has been properly formed, and my
response should match my expectations according to the Twitter API.

However, when I attempt to load the XML template...

RuntimeError in SearchController#user_search
Not all elements respond to to_xml

EXPLOSIONS EVERYWHERE!

I've tried a few things, tweaking some ends here and there, but
nothing seems to be working. Even when I change the request to be
explicitly XML, it STILL says that not all elements respond to to_xml
which is so bizarre, words don't properly describe it!

I'm at wits end, and I'm wondering if you could help a poor soul in
need. :'(

Reply all
Reply to author
Forward
0 new messages