Hi we are new to ruby on rails development and would like to have a solution for the below scenario. we have created a complex object which contains two struct type objects one being an array type, when we try to return this complex object from a method ,we are getting a message like "dont know how to cast". can the members pls respond on the same, thanks in advance Rgds chandra shekar G -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
chandra shekar G wrote:> we are new to ruby on rails development and would like to have a > solution for the below scenario. > > we have created a complex object which contains two struct type objects > one being an array type, when we try to return this complex object from > a method ,we are getting a message like "dont know how to cast".Could you post an example of the code? -- Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
# API class
class SampApi < ActionWebService::API::Base
api_method :GetInfo, :expects => [:string,:string], :returns
=>[CompleteInfo]
end
# struct class TP
class TP < ActionWebService::Struct
member :Name, :string
member :Address, :string
end
# struct class DR
class DR < ActionWebService::Struct
member :Price, :string
member :Tax, :string
end
# Composite class
class CompleteInfo
def initialize
@an_array = []
end
class TP < ActionWebService::Struct
end
class DR < ActionWebService::Struct
end
def assign_to_array (item)
@an_array << item
end
end
# Controller class
class ContentController < ApplicationController
def GetInfo(param0,param1)
p1 = @params[''param0'']
p2 = @params[''param1'']
completeInfo = CompleteInfo.new
tP = CompleteInfo::TP.new()
dR1 = CompleteInfo::DR.new()
dR2 = CompleteInfo::DR.new()
dR3 = CompleteInfo::DR.new()
#TP
tP.Name = "user"
tP.Address = "IN"
#DR
dR1.Price = "10"
dR1.Tax = "1"
dR1.Price = "20"
dR1.Tax = "2"
dR3.Price = "30"
dR3.Tax = "3"
completeInfo.assign_to_array(dR1)
completeInfo.assign_to_array(dR2)
completeInfo.assign_to_array(dR3)
completeInfo
end
end
after execution of the above class the error message displayed is
"Don''t know how to cast CompleteInfo to CompleteInfo"
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---