Paul Cortens
2008-Mar-13 07:39 UTC
[Facebooker-talk] ActionView::TemplateError when FQL query does not return any results
I submitted this as a bug here: http://rubyforge.org/tracker/index.php?func=detail&aid=18799&group_id=4187&atid=16130 However, I just realized that I probably should have posted here first. Has anyone else had a similar experiance with queries that don''t return results? I have the following FQL Query: "SELECT uid FROM user WHERE has_added_app = 1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = #{@current_facebook_user.id})" It usually works just fine. However, in the unlikely case where a user has no friends, I get this error: ActionView::TemplateError (You have a nil object when you didn''t expect it! The error occurred while evaluating nil.name) If a make these changes ... Index: vendor/plugins/facebooker/lib/facebooker/parser.rb ==================================================================--- vendor/plugins/facebooker/lib/facebooker/parser.rb (revision 200) +++ vendor/plugins/facebooker/lib/facebooker/parser.rb (working copy) @@ -249,7 +249,11 @@ def self.process(data) root = element(''fql_query_response'', data) first_child = root.children.reject{|c| c.kind_of?(REXML::Text)}.first - [first_child.name, array_of_hashes(root, first_child.name)] + if first_child.nil? + [nil, array_of_hashes(root, nil)] + else + [first_child.name, array_of_hashes(root, first_child.name)] + end end end =================================================================== ... then things seem to work well. I am sorry that I don''t yet know enough about the facebook api or facebooker to turn this into a real patch. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/facebooker-talk/attachments/20080313/320f3ff8/attachment-0001.html
Apparently Analagous Threads
- trouble with MyPublisher.deliver_story
- Flashing Window in Quicken
- Text Mining with Facebook Reviews (XML and FQL)
- rails 2.3.2, active scaffold, nested, ActionView::TemplateError (undefined method `format_column' for #<ActionView::Base:
- validates_associated -- explicitly setting collection?