Wasn''t sure what subject best described what I need. I have a
webservice that returns a struct CustomerRec that contains a customer
and the customer''s transactions and subscriptions. However, I want to
make the transactions and subscriptions optional. It''s easy enough to
just not fill the subscriptions and transactions members of
CustomerRec, but the Customer query still loads the associations which
is not necessary if I''m not returning them. If I could just create a
class like CustomerWithoutAssociations that did not have the
associations and use it in place of Customer that would work, but
Customer is already defined as a member of CustomerRec, so that won''t
work. Can I redefine members of CustomerRec at runtime? Other
options?
class CustomerRec < ActionWebService::Struct
member :subscriptions, [Subscription]
member :transactions, [TransactionRec]
member :customer, Customer
end
class Customer < ActiveRecord::Base
has_many :txns, :foreign_key => ''customer_id''
has_many :subscriptions, :foreign_key => ''customer_id''
end
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---