Dirk Breuer
2006-Jan-05 17:26 UTC
[Rails] ActiveRecord model classes not allowed in :expects
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 -- Posted via http://www.ruby-forum.com/.
Dirk Breuer
2006-Jan-05 17:40 UTC
[Rails] Re: ActiveRecord model classes not allowed in :expects
By the way another WebService related question: I want to give the Model class that should be send over the wire an Array which can holds the children of that Model (The model has a tree like structure). Is this possible? I found nothing about this topic neither in the Agile Rails Book nor somewhere else. Thanks again Dirk -- Posted via http://www.ruby-forum.com/.
James
2006-Jan-13 23:28 UTC
[Rails] Re: ActiveRecord model classes not allowed in :expects
Dirk Breuer wrote:> Hi, > > I have a strange problem while using WebService API which expects an > ActiveRecord derivate. > > This is the code of the API ......snip...> > When I invoke the service.wsdl URL I''m getting the error from the Topic > (Complete Error page follows):...snip... I am seeing the same thing with Rails 1.0. I did a google search and found this diff: http://dev.rubyonrails.org/changeset/815?format=diff Basically, I think they now turn it off by default due to the possible security issues associated with anyone being able to serialize an ActiveRecord class and (possibly) blindly saving it. It appears that they may have a flag that can be set to allow this to occur. But, according to the Rails book, there is a class called ActiveWebService::Struct that can be used in its place as an expects parameter to achieve the same thing and offer more security (page 427). I''m trying to determine how I want my SOAP service to look, so I may either 1) pass the fields as native types and construct the ActiveRecord instance on the AWS controller or 2) use a Struct subclass. Seems like a good RoR generator could be written to write the struct from a given AR model to keep them in sync and allow the Struct to be a more of a ''value object''. Something to consider at least... -- Posted via http://www.ruby-forum.com/.
Guest
2006-Jan-26 22:47 UTC
[Rails] Re: ActiveRecord model classes not allowed in :expects
> http://dev.rubyonrails.org/changeset/815?format=diff > Basically, I think they now turn it off by defaultEven when you set class_inheritable_option :allow_active_record_expects, true it fails for me with Internal protocol error: 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? Backtrace: /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1401:in `respond_to?'' .... I''m not too worried about the security concerns they mention, I still have to create a struct with the same parameters as the object. Maybe I''m missing something about the serializition. But, this runs in a "trusted enivorment".> Seems like a good RoR generator could be written to write the struct > from a given AR model to keep them in sync and allow the Struct to be a > more of a ''value object''. Something to consider at least...This would be ok with me. I don''t like having to hand create a struct for my classes. And finally, if anyone has a :expects passing in a active_record object please explain how they''re doing it. I wasted a whole day messing with this. Thanks, Russ russ_barber@yahoo.com -- Posted via http://www.ruby-forum.com/.
Possibly Parallel Threads
- HELP!! - ActiveRecord derivates in AWS :expects method
- Re: [PATCH] v2v: Preserve VM Generation ID (RHBZ#1598350).
- [PATCH] v2v: Preserve VM Generation ID (RHBZ#1598350).
- [PATCH 0/2] genid: ACPI Windows generation ID updates
- Re: [PATCH] v2v: Preserve VM Generation ID (RHBZ#1598350).