HELP! - ActiveRecord derivates in AWS :expects method

Hi,

I have a strange problem while using WebService API which expects an
ActiveRecord derivate.

This is the code of the API …


class HarvesterApi < ActionWebService::API::Base
api_method :send_measurand,
:expects => [{:measurand => Measurand}, {:eaiSystemName =>
:string}]
end

… and this of my Model


class Measurand < ActiveRecord::Base

belongs_to :eai_system
belongs_to :measurement_error
acts_as_tree :order => “genId”

Constants for validation of measurand scope

CLASSIFICATION_BEAN = “Bean”
CLASSIFICATION_APPLICATION = “Application”
CLASSIFICATION_WORKFLOW = “Workflow”

Validation part

validates_presence_of :name, :genId, :classification

validates_uniqueness_of :genId,
:message => “The GenID must be unique”

validates_inclusion_of :classification,
:in => [ CLASSIFICATION_BEAN,
CLASSIFICATION_APPLICATION, CLASSIFICATION_WORKFLOW ],
:message => “Classification must be of
the following: #{CLASSIFICATION_BEAN}, #{CLASSIFICATION_APPLICATION},
#{CLASSIFICATION_WORKFLOW}”

end

When I invoke the service.wsdl URL I’m getting the error from the Topic
(Complete Error page follows):


ActiveRecord model classes not allowed in :expects

How can that be? Did I any mistakes? That would be no suprise, bacause
I’m new to Rails and Ruby. But as I understand it, it is possible to use
a AR as structured type in the method signature of a WebService.

Thanks for your help.

Dirk

You need to enable the option in your controller:

ActionWebService::API::Base.allow_active_record_expects = true

Let me know if this works for you…I enabled it and stopped getting the
“ActiveRecord model classes not allowed in :expects” error, but now I
get “NoMethodError (You have a nil object when you didn’t expect it!”.

Hopefully this will work better for you than me.

Dirk Breuer wrote:

ActiveRecord derivate.

This is the code of the API …


class HarvesterApi < ActionWebService::API::Base
api_method :send_measurand,
:expects => [{:measurand => Measurand}, {:eaiSystemName =>
When I invoke the service.wsdl URL I’m getting the error from the Topic
(Complete Error page follows):


ActiveRecord model classes not allowed in :expects

How can that be? Did I any mistakes? That would be no suprise, bacause
I’m new to Rails and Ruby. But as I understand it, it is possible to use
a AR as structured type in the method signature of a WebService.

Thanks for your help.

Dirk