I'm assuming you are meaning you don't want ActiveRecord models.  If 
thats' the case, then yes it is possible.  In fact, I currently do that 
in a couple apps that access objects through XML RPC calls.  Here is how 
I do it, which will give you validations on errors.

class ModelWithoutDatabase
   def save() raise NotImplementedError end
   def save!() raise NotImplementedError end
   def update_attribute() raise NotImplementedError end
   def new_record?() true end

   include ActiveRecord::Validations
   # include ActiveRecord::Errors

   def initialize(attributes = nil)
      self.attributes = attributes
   end

   def attributes=(new_attributes)
      return unless new_attributes
      new_attributes.each do |k, v|
         k = "#{k}="
         send(k, v) if respond_to?(k)
      end
   end

   def self.human_attribute_name(attribute_key_name) #:nodoc:
     attribute_key_name.humanize
   end

   # Rails 2.2.2 fixes
   def self.self_and_descendents_from_active_record; [self]; end
   def self.human_name; self.name; end

end


The cool thing about this is that I can still call Model.valid? and use 
the validation stuff of ActiveRecord. Then I have my RPC objects that 
are Models inherit from the class above so:

class Contact < ModelWithoutDatabase
  def method1
    rpc calls
  end

  def method2
    rpc calls
  end
end


I hope that helps.
-- 
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to