Vote #66510
完了Bug in index.xml.builder (issues)
100%
説明
in this file at :
xml.issues :type => 'array' , :count => @issue_count do
The ":count" parameter will cause an error calling issues from activeresource :
can't typecast "1" ["/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/hash/conversions.rb:182:in `typecast_xml_value'", "/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/hash/conversions.rb:208:in `typecast_xml_value'", "/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/hash/conversions.rb:199:in `inject'",
If you delete this parameter, all is working fine.
My configuration
Ruby version 1.8.7 (i486-linux)
RubyGems version 1.3.5
Rack version 1.0
Rails version 2.3.5
Active Record version 2.3.5
Active Resource version 2.3.5
Action Mailer version 2.3.5
Active Support version 2.3.5
Application root /var/www/redmine
Environment development
Database adapter postgresql
Database schema version 20091227112908
journals
REST API bug?
I tried to run the script http://www.redmine.org/wiki/redmine/Rest_api_with_ruby. Displays an error message: /home/artem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/hash/conversions.rb:182:in `typecast_xml_value': can't typecast "2" (RuntimeError)
I deleted :count => @issue_count in app/views/issues/index.xml.builder and all earned.
--------------------------------------------------------------------------------
I wrote a script rest.rb:
<pre>
<code class="ruby">
require 'rubygems'
require 'active_resource'
class Issue < ActiveResource::Base
self.site = 'http://www.redmine.org/'
end
issues = Issue.find(:all)
puts issues.first.subject</code></pre>
$ ruby rest.rb
/home/artem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/hash/conversions.rb:182:in `typecast_xml_value': can't typecast "1794" (RuntimeError)
--------------------------------------------------------------------------------
I wrote a script rest2.rb:
<pre>
<code class="ruby">
require 'rubygems'
require 'active_resource'
class Project < ActiveResource::Base
self.site = 'http://www.redmine.org/'
end
projects = Project.find(:all)
puts projects.first.name</code></pre>
$ ruby rest2.rb
Redmine
It works!
--------------------------------------------------------------------------------
thats what i said, if you delete the :count parameter, all is working fine !
--------------------------------------------------------------------------------
I've removed the count attribute in issues.xml. It's not ideal because of the pagination won't show all of the issues but it breaks ActiveResource.
Here's the full error for the search:
<pre>
RuntimeError: can't typecast "368"
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/hash/conversions.rb:182:in `typecast_xml_value'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/hash/conversions.rb:208:in `typecast_xml_value'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `inject'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/hash/conversions.rb:207:in `each'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/hash/conversions.rb:207:in `inject'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/hash/conversions.rb:207:in `typecast_xml_value'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/hash/conversions.rb:164:in `from_xml'
from /usr/lib/ruby/gems/1.8/gems/activeresource-2.3.5/lib/active_resource/formats/xml_format.rb:19:in `decode'
from /usr/lib/ruby/gems/1.8/gems/activeresource-2.3.5/lib/active_resource/connection.rb:138:in `get'
from /usr/lib/ruby/gems/1.8/gems/activeresource-2.3.5/lib/active_resource/base.rb:639:in `find_every'
from /usr/lib/ruby/gems/1.8/gems/activeresource-2.3.5/lib/active_resource/base.rb:582:in `find'
from (irb):5
from :0
</pre>
--------------------------------------------------------------------------------
related_issues
relates,Closed,6140,REST issues response with issue count limit and offset
duplicates,Closed,5226,'can't typecast' in REST API for issues