Forum: Ruby on Rails HELP!! - ActiveRecord derivates in AWS :expects method

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8b6f3bdd655ba2a19cda645e2150f34d?d=identicon&s=25 Dirk Breuer (samwise23)
on 2006-01-11 10:17
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
4d36263101dd43d8c3d3692fccbc7147?d=identicon&s=25 Chris Goodwin (Guest)
on 2006-05-12 22:02
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
This topic is locked and can not be replied to.