Ruby on Rail and Google Gadgets - Are they compatible?

Hi all,

Has anyone created a url type Gadget that hits a ruby on rails
controller? Seems that methods that process request parameters fail
before any code that I’ve written is reached. Am I missing something
here? Stacktrace and failing methods are included below. Thanks in
advance for any help!

James

You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.include?
/opt/csw/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/cgi_ext/cgi_methods.rb:49:in
parse_request_parameters' /opt/csw/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/cgi_ext/cgi_methods.rb:47:inparse_request_parameters’
/opt/csw/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/cgi_process.rb:70:in
request_parameters' /opt/csw/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/request.rb:12:inparameters’
/opt/csw/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/session_management.rb:122:in
set_session_options_without_components' /opt/csw/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/components.rb:178:inset_session_options’
/opt/csw/lib/ruby/gems/1.8/gems/actionpack-1.12.3/lib/action_controller/session_management.rb:116:in
process' /opt/csw/lib/ruby/gems/1.8/gems/rails-1.1.4/lib/dispatcher.rb:38:indispatch’
/opt/csw/lib/ruby/gems/1.8/gems/mongrel-0.3.13/lib/mongrel/rails.rb:82:in
process' /opt/csw/lib/ruby/1.8/thread.rb:135:insynchronize’
/opt/csw/lib/ruby/gems/1.8/gems/mongrel-0.3.13/lib/mongrel/rails.rb:80:in
process' /opt/csw/lib/ruby/gems/1.8/gems/mongrel-0.3.13/lib/mongrel.rb:529:inprocess_client’
/opt/csw/lib/ruby/gems/1.8/gems/mongrel-0.3.13/lib/mongrel.rb:528:in
process_client' /opt/csw/lib/ruby/gems/1.8/gems/mongrel-0.3.13/lib/mongrel.rb:597:inrun’
/opt/csw/lib/ruby/gems/1.8/gems/mongrel-0.3.13/lib/mongrel.rb:596:in
run' /opt/csw/lib/ruby/gems/1.8/gems/mongrel-0.3.13/lib/mongrel.rb:585:inrun’
/opt/csw/lib/ruby/gems/1.8/gems/mongrel-0.3.13/lib/mongrel.rb:909:in
run' /opt/csw/lib/ruby/gems/1.8/gems/mongrel-0.3.13/lib/mongrel.rb:908:inrun’
/opt/csw/lib/ruby/gems/1.8/gems/mongrel-0.3.13/bin/mongrel_rails:143:in
run' /opt/csw/lib/ruby/gems/1.8/gems/mongrel-0.3.13/lib/mongrel/command.rb:188:inrun’
/opt/csw/lib/ruby/gems/1.8/gems/mongrel-0.3.13/bin/mongrel_rails:247
/opt/csw/bin/mongrel_rails:18

Returns the request (POST/GET) parameters in a parsed form where

pairs such as “customer[address][street]” /

“Somewhere cool!” are translated into a full hash hierarchy, like

{ “customer” => { “address” => { “street” => “Somewhere cool!” } } }

def CGIMethods.parse_request_parameters(params)
parsed_params = {}

for key, value in params
value = [value] if key =~ /.*[]$/
unless key.include?(’[’) <- THIS IS WHERE THE CODE IS FAILING
# much faster to test for the most common case first (GET)
# and avoid the call to build_deep_hash
parsed_params[key] = get_typed_value(value[0])
else
build_deep_hash(get_typed_value(value[0]), parsed_params,
get_levels(key))
end
end

parsed_params
end

key can’t exicute include? because it is a string not an array
however

if value != nil and value.is_a(‘array’) and not value.include?

may work. if you simply want to determin if there is a [ char in the key
use

if key != nil and key.match(’[’)

Thanks Keynan, I was trying to avoid changing core CGI-related code.
I wondered if there was anyone else out there using Rails with Gadets,
and if it is simply something I am doing wrong. Are you using Rails
with Gadgets?

Thanks,
James